Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Crosstab like Access ???
Message
De
23/01/2002 22:56:07
 
 
À
23/01/2002 16:44:07
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00609339
Message ID:
00609513
Vues:
9
No. SQL Server does not have any native mechanism to do cross-tabs. You can either implement the functionality on the client or, if you have a fixed number of columns, use the CASE function.

SELECT
office.name,
SUM(CASE WHEN sales.month=1 THEN sales.amt ELSE 0 END) AS jansales,
SUM(CASE WHEN sales.month=2 THEN sales.amt ELSE 0 END) AS febsales,
...
FROM
office
INNER JOIN sales ON sales.officeid = office.officeid
GROUP BY
office.name

-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform