如何在SQLITE中获取每个用户的最新进入日期?
如果我通过auth_user.id 进行组,它会给我列表。如果分组的用户有多个行,我会在用户第一次填写我的表格时得到日期。如果我按日期订购(
desc
),则在他第一次填写表格的日期之前就订购了它。
如何获得他填写表格和用户分组的最后一次日期?现在我在这里:
SELECT *
FROM answers
ORDER BY date DESC
它提供了所有用户的所有条目和每个日期下降。没关系。
SELECT *
FROM answers
GROUP BY user_id
ORDER BY date DESC
现在,它提供了分组的数据,但是每个用户的第一个日期。如果分组,我该如何获得最后日期?
If I make a GROUP BY auth_user.id
it gives me the list. If the users who are grouped has more than one rows I get the date when the user filled my form first time. If I order it by date (DESC
), it orders it by the date when of the first time he filled the form.
How can I get the date of the last time when he filled the form and the users are grouped? Now I'm here:
SELECT *
FROM answers
ORDER BY date DESC
It gives all the entries of all users and every dates descending. It's okay.
SELECT *
FROM answers
GROUP BY user_id
ORDER BY date DESC
Now it gives grouped data but with the first date of every users. How can I get the last date if grouped?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
max(date)
获得每个用户的最新日期。You can use
max(date)
to get the most recent date for each user.