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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Development Tools
 Reporting Services Development
 Multiple Groups bys
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mrb2073
Starting Member

USA
1 Posts

Posted - 07/22/2014 :  11:53:20  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

2780 Posts

Posted - 07/23/2014 :  11:05:02  Show Profile  Reply with Quote
read this about cross-tab queries:

http://www.sqlservercentral.com/articles/T-SQL/63681/
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000