Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crosstab query 1

Status
Not open for further replies.

grnzbra

Programmer
Mar 12, 2002
1,273
0
0
US
Does SQL Server have anything like the Access crosstab query?
 

Here is a cross tab query example from BOL.


This is the SELECT statement used to create the rotated results:

SELECT Year,
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 Northwind.dbo.Pivot
GROUP BY Year
GO


Look up cross-tab reports in BOL for more details.

Matt

 
Thank you.

I was trying to find it in BOL without the hyphen.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top