Nadh Nadh - 15 days ago 8
MySQL Question

mysql :query count with having condition

My dadtabase data like this in table:

id name view date time
1 abc 1 23/11/16 00:01:06
2 abc 2 23/11/16 02:52:58
3 abc1 1 23/11/16 02:52:58
4 abc2 1 23/11/16 02:52:58
5 abc2 2 23/11/16 02:52:58
6 abc3 1 23/11/16 02:52:58


I want to get total count of views as per day wise which are having view =1,(if the same with view =1,2 dont need) like

id name view date time
1 abc1 1 23/11/16 02:52:58
2 abc3 1 23/11/16 02:52:58

Answer

try the following query

select id, name, date , sum(view) as viewcount
from tablename
group by date
having sum(views) = 1;