I have 6 queries like below.
The output I want is: Category(=the 1st column), Yr, Qtr, Cnt.
SELECT 'Medication', YEAR(convert (datetime,NurDateOfOcc)) AS Yr,
DATEPART(qq,convert (datetime,NurDateOfOcc)) AS Qtr,
COUNT(*) AS Cnt
FROM ....
SELECT 'Falls', YEAR(convert (datetime,NurDateOfOcc)) AS Yr,
DATEPART(qq,convert (datetime,NurDateOfOcc)) AS Qtr,
COUNT(*) AS Cnt
FROM ...
Each of 6 queries will return the outputs like below.
Medication 2002 2 553
Medication 2002 3 527
Medication 2002 4 487
Medication 2003 1 439
Medication 2003 2 535
..............
Falls 2002 2 1
Falls 2002 3 85
Falls 2002 4 8
Falls 2003 1 70
Falls 2003 2 66
Falls 2003 3 84
...............
What I want is the outputs look as:
Yr Qtr Medication Falls ... 4 Other categories ..
2002 2 553 1 .....
2002 3 527 85 .....
Please advise.
Thanks so much
The output I want is: Category(=the 1st column), Yr, Qtr, Cnt.
SELECT 'Medication', YEAR(convert (datetime,NurDateOfOcc)) AS Yr,
DATEPART(qq,convert (datetime,NurDateOfOcc)) AS Qtr,
COUNT(*) AS Cnt
FROM ....
SELECT 'Falls', YEAR(convert (datetime,NurDateOfOcc)) AS Yr,
DATEPART(qq,convert (datetime,NurDateOfOcc)) AS Qtr,
COUNT(*) AS Cnt
FROM ...
Each of 6 queries will return the outputs like below.
Medication 2002 2 553
Medication 2002 3 527
Medication 2002 4 487
Medication 2003 1 439
Medication 2003 2 535
..............
Falls 2002 2 1
Falls 2002 3 85
Falls 2002 4 8
Falls 2003 1 70
Falls 2003 2 66
Falls 2003 3 84
...............
What I want is the outputs look as:
Yr Qtr Medication Falls ... 4 Other categories ..
2002 2 553 1 .....
2002 3 527 85 .....
Please advise.
Thanks so much