Reputation: 157
Lets look at the following table:
Name TIMESTAMP STATUS
Task1 01-01-2019 COMPLETE
Task1 01-01-2019 COMPLETE
Task2 01-01-2019 COMPLETE
Task3 02-01-2019 NOT COMPLETE
Task4 01-01-2019 COMPLETE
Task4 02-01-2019 COMPLETE
What I want the output to be like is:
Date TaskName How many completed?
January stats Task1 2
February stats Task2 1
Day 1 of march Task3 0
Day 2 of march Task4 1
Day 3 of march Task1 0
Basically, I want the output table to show the total count of completed per task for each month before the current month, then on the following rows it shows the completed task count for each day in that month. Currently, I have got two separate output tables where one shows total completed task count for every month, then another output table that shows the total completed task count for each day in the current month. How can I join these two?
Upvotes: 0
Views: 34
Reputation: 1
this should work
with c as
(
select timestamp, taskname, count(status) as Counter from your_table
group by date, name )
select timestamp as date, name as TaskName, Counter as HowManyCompleted
from c
Upvotes: 0