我有一个表'Notification_details',我在其中查询以获取具有以下MySQL查询的唯一记录
从中选择userid,max(notification_date)作为notification_date notification_details group by userid order by notification_date asc
给出结果,其中userid是唯一的,notification_date是最新的(max)。 现在,我想扩展MySQL命令,以查询我获得的结果的两个日期:
任何想法,如何扩展上面的MySQL命令?
答案 0 :(得分:2)
如果我没有错过了解你:
SELECT alias.*
FROM (select userid, max(notification_date) as notification_date from notification_details group by userid order by notification_date asc) alias
WHERE alias.notification_date BETWEEN DATE1 AND DATE2