I have data in tableA which only holds tickets that were reopened.
ticket date owner reopencount
123 2020-01-02 SP 1
124 2020-01-04 SP 1
234 2020-02-04 PS 1
And tableB has all ticket values:
ticket date owner
123 2020-01-01 SP
123 2020-01-02 SP
124 2020-01-03 SP
124 2020-01-04 SP
125 2020-01-04 SP
232 2020-02-02 PS
234 2020-02-03 PS
234 2020-02-04 PS
What I expect to use is tableA along with the total count of tableB in monthly counts.
Expected result:
ticket date owner month_overall_count
123 2020-01-02 SP 3
124 2020-01-04 SP 2
234 2020-02-04 PS 3
Im trying to select everything from tableA and only the count from tableB, as tableB has so much data and I don't really want to load it every time.
What I tried is :
select *
from tableA a
inner join (
select format(date, 'MMM-yyyy') as month, count(*)
from tableB
) b on format(a.date, 'MMM-yyyy') = format(b.date, 'MMM-yyyy')
But this will not give me field wise count if I need it later. Do I have to provide every field I'm using on tableA?
How do I get this?