问题
I would like to filter by day of the week (Thursday in my example) in one statement. The next statement works (please note that date
is a column name):
SELECT CAST (strftime('%w', date) AS Integer) = 4 FROM sales WHERE id=123;
However, when I include the above filter I get no results:
SELECT * FROM sales WHERE id=123 AND (SELECT CAST (strftime('%w', date) AS Integer) = 4 FROM sales WHERE id=123) = 1;
回答1:
Although I do not know why the previous code doesn't work I post an alternative working solution:
SELECT * FROM sales WHERE id=123 AND CAST (strftime('%w', date) AS Integer) = 4;
来源:https://stackoverflow.com/questions/45904943/sqlite-filter-by-day-of-the-week-in-one-statement