T-SQL Guru - SQL Server PIVOT

It's time for another May TechNet Guru winner!

Naomi N is our T-SQL TechNet Guru for May! See more about the Technology Guru TechNet Wiki for May contest.

Naomi N's avatar

About Naomi: I am an IT professional with more than 15 years of experience in variety of programming languages and technologies. I am a Microsoft Community Award Recipient and Personality of the Year at UniversalThread.com forum in 2008,2009,2010,2011.

 

Here is Naomi's second winning article:

 

Here are all the May T-SQL winners:

Transact-SQL Technical Guru - May 2013

Gold Award Winner

 

Naomi N Dynamic Pivot on Multiple Columns
  • "Great example of what we want on TechNet Wiki"

Gold Award Winner

 

Naomi N SQL Server PIVOT
  • "Clean, clear and well presented."
  • "I liked this more than the dynamic entry, based on the explanation and presentation."

Silver Award Winner

 

SQL Server resource re-balancing in Failover Cluster
  • "My favourite, based on the technical level."
  • "Perfect contribution, includes original forum link"

Bronze Award Winner

 

Naomi N T-SQL: Date-Related Queries
  • "Well described; includes original link."
  • "Great post; just what we need for the wiki."

A big thanks to Naomi. This was exactly what we'd hoped for, and Naomi swept the board. Naomi takes two gold medals, as both articles scored exactly the same, when all votes were added up! Also thanks to Andrew for another excellently crafted article, that ticked so many boxes.

 

 

And here's an excerpt from the article:

The pivot solution by itself is not complex, it's a simple static PIVOT. But the thread originator was having a problem arriving to it. The main problem is to understand, that all columns which are not mentioned in the PIVOT aggregate function in the PIVOT clause will be aggregated, so if there is a column with unique values in the source table for the pivot and it is not mentioned in the PIVOT clause, it will be a source of the aggregation and therefore the result will have as many rows as you have unique columns in the table defeating the main purpose of the PIVOT.
.

 

Read the rest here:

SQL Server PIVOT

 

Thanks to Naomi for all your great contributions to the TechNet Guru contest! You can read about all the May winners here: TechNet Guru Awards - May 2013

 

Also, for the June Guru competition, see TechNet Guru June Roundup & Commentary.

 

Are you a Wiki Ninja? https://technet.com/wiki

- User Ed