May 3, 2003 at 4:51 am
Hi,
I need a report which is called Spending by Budget source,i get the data from a view and its structure is
-----------
Program Year,
Quarter,
FundSource Name,
Amount
-----------
I need to prepare a report which wil be in this format
--------------
Fund source name Q1 Q2 Q3 Q4
------------------------
Q1,Q2,Q3,Q4 represent Amount in Quarter1,Quarter2,Quarter3,Quarter4 respectively
May 3, 2003 at 5:42 pm
I think this query should work out...
and you should check out this excellent script by Antares on pivot tables http://www.sqlservercentral.com/scripts/contributions/204.asp
SELECT
FundSourceName,
SUM(CASE [Quarter] WHEN '1' THEN Amount ELSE 0 END) as Q1,
SUM(CASE [Quarter] WHEN '2' THEN Amount ELSE 0 END) as Q2,
SUM(CASE [Quarter] WHEN '3' THEN Amount ELSE 0 END) as Q3,
SUM(CASE [Quarter] WHEN '4' THEN Amount ELSE 0 END) as Q4
FROM Forum GROUP BY FundSourceName
May 5, 2003 at 1:04 am
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply