I have the following query and I would like to add all the views of a specific date as shown below.
SELECT SUM("videoView"."views"), "videoView"."startDate"::timestamp::date
FROM "videoView"
WHERE "videoView"."videoId" =23
AND ("videoView"."startDate"::timestamp::date)= '2021/11/25'
GROUP BY "videoView"."startDate"
The result I want is:
sum date
3 2021/11/25
The result i am getting is
sum date
2 2021/11/25
1 2021/11/25
CodePudding user response:
As mentioned by @joachim-isaksson, You can do this like following:
SELECT SUM("videoView"."views"), "videoView"."startDate"::timestamp::date
FROM "videoView"
WHERE "videoView"."videoId" =23
AND ("videoView"."startDate"::timestamp::date)= '2021/11/25'
GROUP BY "videoView"."startDate"::timestamp::date;
CodePudding user response:
select SUM(WordCount) as 'words per day'
from @WordsCount
group by DateAdded