Reputation: 295
I have one table having column :
ID| rect_id| vieweed_user_id| view_count|view_date
1 | 1 | 1 | 1 |2017-03-07 10:54:21
2 | 1 | 2 | 1 |2017-03-08 01:00:45
3 | 1 | 3 | 1 |2017-03-08 12:54:12
I want to find count for all view_count values according to view_date,for example
view_date | view_count
2017-03-08 | 2
2017-03-07 | 1
but my problem is I want to find all counted view_count values between a specified date range for example
from 2016-03-08 to 2017-03-08
Upvotes: 0
Views: 45
Reputation: 290
try this.
SELECT view_date, sum(view_count) as total_count FROM TABLE_NAME WHERE view_date >= '2016-03-08' AND view_date <= '2017-03-08' group by view_date
Upvotes: 2
Reputation: 1192
You need to filter between dates and group by date to get the output you need
select view_date,sum(view_count) from TABLE_NAME where view_date between ('2016-03-08' and '2017-03-08') group by view_date
Upvotes: 0