Nitin Jain Nitin Jain - 6 months ago 11
SQL Question

selecting rows which have occurred more than three times

I have a table active_users and from that i want to select the rows where user_id has occurred more than 2 times and notified = 0 .Want single result only

enter image description here

Query Result Required

Id User_id Mobile last_seen notified
1 25853 XXXXXXXX 14-May-2016 17:11:12 0

Answer
SELECT *
FROM active_users
WHERE notified = 0
GROUP BY user_id
HAVING COUNT(id) >2
Comments