sqlite - asc/desc result is inverted [duplicate] - sqlite

This question already has answers here:
How to use SQL Order By statement to sort results case insensitive?
(3 answers)
Closed 2 years ago.
Why is the following query working inverse? I'd expect that asc order them in alphabetical order..

Apply CAPS to the commands and apply 'NOCASE' function like:
SELECT * FROM giochi ORDER BY nomegioco NOCASE (ASC)

Related

How to filter rows by using datetimes present in the row and datetime('now') [duplicate]

This question already has answers here:
SQLite DateTime comparison
(14 answers)
Closed 3 months ago.
Given the table Use, defined as
CREATE TABLE Use(date TEXT NOT NULL, id TEXT PRIMARY KEY);
I want to make a query to find "All uses before today", however SQLite is not behaving as I expect and return the wrong value.
I tried to query using my table as such:
SELECT * FROM Use WHERE date <= datetime('now')
The problem here is that date might not be in the same format that datetime returns.
You need first to convert the date to use the same format, by using the datetime function on it as well, and then you can compare both correctly:
SELECT * FROM Use where datetime(date) <= datetime('now')

How to set all values in a column to empty (null)? [duplicate]

This question already has an answer here:
How to update an entire column in sqlite? [duplicate]
(1 answer)
Closed 1 year ago.
How to set all values in a column to empty (null)?. To reset the value of a nullable column for every row in a table.
Just ignore the WHERE clause would do the trick. How to change a value in a column on a SQLite database?
UPDATE table_name SET column_name = NULL

How to use is.null() using brackets [] rather than the dollar sign $? [duplicate]

This question already has answers here:
To find whether a column exists in data frame or not
(5 answers)
Closed 3 years ago.
Fairly simple question. I am using is.null() in a loop to see if variables exist within many data frames.
is.null(mtcars$ddd)
TRUE
This works fine. But I need to insert the variables as text like this:
is.null(mtcars[, c("ddd")])
Error in `[.data.frame`(mtcars, , c("ddd")) : undefined columns selected
Is there any way to use the is.null() function while inserting the variable name as text?
Use
is.null(mtcars[["ddd"]])
or
!hasName(mtcars, "ddd")

'rowid' column is not autoincrementing [duplicate]

This question already has answers here:
ROWID INTEGER PRIMARY KEY AUTOINCREMENT - How to insert values?
(5 answers)
Closed 6 years ago.
A similar question has been asked before, but the query is embedded in java and perhaps less clear to a total novice who would be asking this type of question.
I think the 'rowid' column is not auto-populating/auto-incrementing. Table, insert statement, and error code as follows:
CREATE TABLE T (rowid INTEGER PRIMARY KEY, c1 REAL, c2 REAL);
insert into T values (8,9);
Error code in my DB Browser is:
table T has 3 columns but 2 values were supplied: insert into T values (1,2);
I have other code that is very similar but not producing this error. Any help is greatly appreciated! Thanks!!
This isn't a SQLite problem, it's a problem with your DB browser enforcing that values for all three columns must always be present.
One option to get around this would be to insert NULL for the rowid column. This should force SQLite to assign the next logical value, which is the behavior you want anyway:
INSERT INTO T values (NULL, 1, 2);

How to grep records which has a full stop in R [duplicate]

This question already has answers here:
grepl for a period "." in R?
(2 answers)
Closed 6 years ago.
I am trying to grep all the records of a dataframe which has a full stop in it. But it returns all the records in the dataframe no matter it has a full stop or not.
dot=e[grep(".", e$e1),]
View(dot)
Can anyone help me to do this in the correct way please?
You can either use the fixed=True argument, or use "\."
dot=e[grep(".", e$e1, fixed=T),]
or
dot=e[grep("\\.", e$e1),]
The first option is probably preferable.

Resources