[dba-SQLServer] crosstabs in sql

Arthur Fuller artful at rogers.com
Wed Aug 11 16:47:29 CDT 2004


The basic scenario is this:

For each column, use a CASE statement. Look up CASE in BOL and there are
some useful examples. The basic idea is this:

CASE [somecondition] THEN [FieldOfInterest] ELSE 0 (that's zero) END

And you add as many cases as you need. That is the thumbnail to be sure,
but that's the idea. Unfortunately there is no wizard to help you do
this (until SQL 2005 finally hits the streets).

Arthur 

-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Klos,
Susan
Sent: Wednesday, August 11, 2004 5:13 PM
To: 'dba-sqlserver at databaseadvisors.com'
Subject: [dba-SQLServer] crosstabs in sql


How do you create a crosstab query in SQL Server.  I tried doing one in
Access and copying the SQL into SQL Query Analyzer but I can't seem to
get it right.  

 

Susan Klos




More information about the dba-SQLServer mailing list