选择日期时出现问题
以下是我正在提出的一些查询以及收到的结果。我想要最终得到的是月份和年份的列表。所以我想查看 02-2011、03-2011、04-2011 的结果。但我似乎无法理解...我该怎么办?
select date from record;
04-13-2011
04-14-2011
03-14-2011
02-14-2011
sqlite>
select strftime('%m-%Y') from record;
04-2011
04-2011
04-2011
04-2011
sqlite>
select date from record group by date('%m-%Y');
02-14-2011
sqlite>
select strftime('%m-%Y', date) from record group by date('%m-%Y');
note: blank row
sqlite>
Here are some queries I'm making and the results I'm receiving. What I'm trying to end up with is a list of months and years. So I want to see a result of 02-2011, 03-2011, 04-2011. But I can't seem to get it... what should I do?
select date from record;
04-13-2011
04-14-2011
03-14-2011
02-14-2011
sqlite>
select strftime('%m-%Y') from record;
04-2011
04-2011
04-2011
04-2011
sqlite>
select date from record group by date('%m-%Y');
02-14-2011
sqlite>
select strftime('%m-%Y', date) from record group by date('%m-%Y');
note: blank row
sqlite>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许
您的日期似乎是一个字符串列。无论如何,在第二个查询中,您为每行选择当前月份和年份,后续查询的 GROUP BY 子句也是如此。
Maybe
Your date seems to be a string column. Anyway, in the second query you select current month and year for each row, the same goes for
GROUP BY
clause of subsequent queries.