Kiran
Kiran

Reputation: 8518

MySQL Query to select between 2 dates

I have a Table 'Notification_details' where I query to obtain the unique records with the following MySQL query

enter image description here

select userid, max(notification_date) as notification_date from notification_details group by userid order by notification_date asc

Which gives the result, where the userid is unique and the notification_date is the latest( max). Now, I would like to extend the MySQL command to query between 2 dates of the result I have obtained :

enter image description here

Any idea, how to extend the above MySQL command ?

Upvotes: 3

Views: 119

Answers (1)

Leandro Bardelli
Leandro Bardelli

Reputation: 11578

If I didn't missunderstand you:

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

Upvotes: 3

Related Questions