我无法检索查询。 目前我有一个名为“HISTORY”表的表,其中包含字段和数据,例如......
显示日期 |项目类型
2014-10-05 | 0
2014-10-08 | 0
2014-10-07 | 1
2014-10-09 | 1
2014-11-05 | 0
2014-11-05 | 1
我想从历史表中检索一个月的数据并按显示日期排序。
如果 display_date 相同,我还想对 item_type 字段进行排序 0 然后 1。
我的查询语句是select * from history where strftime('%Y-%m-%d',display_date)>=strftime('%Y-%m-%d','now')
and strftime('%Y-%m-%d',display_date)<=date('now', '+1 month') order by display_date DESC;
我的查询只给我排序的显示日期。
但我想从历史表中检索一个月的数据并按显示日期排序。 如果 display_date 相同,我还想对 item_type 字段进行排序 0 然后 1。
显示日期 |项目类型
2014-10-05 | 0
2014-10-05 | 1
2014-10-07 | 1
2014-10-08 | 0
2014-10-09 | 1
2014-11-05 | 1
2014-11-05 | 0
请帮我解答一下。谢谢。
最佳答案
使用此查询:
SELECT *
FROM history
WHERE display_date BETWEEN date('now') AND date('now', '+1 month')
ORDER BY display_date, item_type
关于android - 如何通过检索优先级数据来查询表并在 SQLITE DB 中按顺序排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26206060/