Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 Multiple Groups bys

Author  Topic 

mrb2073
Starting Member

1 Post

Posted - 2014-07-22 : 11:53:20
I have been using SQL for a few years now but am completely new to reporting. I am trying to run a query that returns multiple counts in Visual Studio. Right now I am able to get the numbers I need for the month of Jan but would like to add additional columns for each month to my results. Any help would be appreciated.
Thanks

***************
SELECT CODESSERVICEAUTHREQUESTGROUPS.CODE, COUNT(SAREQUESTS.ID) AS JAN_14
FROM SAREQUESTS INNER JOIN
CODESSERVICEAUTHREQUESTGROUPS ON SAREQUESTS.ASSIGNTOGROUP = CODESSERVICEAUTHREQUESTGROUPS.ID INNER JOIN
CODESSERVICEAUTHREQUESTSTATUSES ON SAREQUESTS.TASKSTATUS = CODESSERVICEAUTHREQUESTSTATUSES.ID
WHERE (SAREQUESTS.ASSIGNTOGROUP IN (2247, 2224, 1068, 52, 2092, 2211, 2197, 2231, 42, 2127, 15, 2214, 2248, 2243, 29, 2278, 51, 2239, 2223, 2249, 2250, 45, 2233,
54, 58, 2226, 2225, 2240, 2182, 2217)) AND (SAREQUESTS.DATERECEIVED < CONVERT(DATETIME, '2014-02-01 00:00:00', 102)) AND
(SAREQUESTS.DATERECEIVED >= CONVERT(DATETIME, '2014-01-01 00:00:00', 102))
GROUP BY SAREQUESTS.ASSIGNTOGROUP, CODESSERVICEAUTHREQUESTGROUPS.CODE
ORDER BY JAN_14 DESC

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-07-23 : 11:05:02
read this about cross-tab queries:

http://www.sqlservercentral.com/articles/T-SQL/63681/
Go to Top of Page
   

- Advertisement -