sqlite filter by day of the week in one statement

為{幸葍}努か 提交于 2020-01-24 01:20:27

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!