From: Plamen Ratchev on 4 May 2010 18:52 Another example is using the PIVOT operator. If you write a query like this: SELECT <columns> FROM Table PIVOT (SUM(col1) FOR col2 IN (...)) AS P; In this case the PIVOT operator will add grouping by all columns from Table that are not used as arguments for PIVOT (col1, col2). Using derived table this can be avoided and you can select only the needed grouping column(s): SELECT <columns> FROM (SELECT col1, col2, group_column FROM Table) AS T PIVOT (SUM(col1) FOR col2 IN (...)) AS P; -- Plamen Ratchev http://www.SQLStudio.com
|
Pages: 1 Prev: DB Mail is is not working. Need help please. Next: VMWare and SQL Server in Production |