1

We have thousands of record in our data and want to count date wise jobs with category through single query. It is Possible? Display required as under

TypesJobs   01  02  03 04 05 06 07        
A            2  1    6  4  1  3  4
B            10 12   8  10 12 9  13
C            3   5   4   3  2  5  4

Here Types of jobs count for a day in date column 01, 02, 03 are date range of the month

juergen d
  • 201,996
  • 37
  • 293
  • 362

1 Answers1

1

You can use conditional aggregation, something like this:

select typesjobs,
       sum(case when month(datecol) = 1 then 1 els e0 end) as month_01,
       sum(case when month(datecol) = 2 then 1 els e0 end) as month_02,
       . . .
from t
where <date condition here>
group by typesjobs;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786