Join | Login | Why Join?   
SQL Server, Oracle, DB2, Sybase, MySQL Help - SSWUG.ORG HACKER SAFE certified sites prevent over 99.9% of hacker crime.
Search SSWUG:   
 
Access to 498 free guest articles, discussions and more, just create your free SSWUG User ID:
Email address:  
This will be your login ID - we'll email you your password - you'll even receive the newsletter, opt-out at any time.
Email to Friend //  Discuss Article //  Rate Article //  Digg Article //  Add to Del.icio.us //  Add to Technorati

Full site membership is required for this article. Already a full member? Login here.
You currently have a guest membership. You can upgrade to full site membership here (free trial available).

Use A Pivot Table to Un-Pivot Data


 Article Abstract:

Developers are frequently required to massage data from one form to another. This is especially common for database queries. I have frequently had to write queries that take normalized data and pivot it into a de-normalized table. For example, I have had to transform sales statistics stored with a separate record for each sales ID and quarter into a single record for each sales ID with separate columns for four quarters. The most efficient method to make this conversion in SQL Server is the use of a Pivot Table. MS Access provides a Cross Tab Query which automates this process. MS Excel has a Pivot Table Wizard that pivots data in a spreadsheet. However, until YUKON is released there is no automated method of performing this task in SQL Server.

To pivot data in SQL Server efficiently we have always utilized a Pivot table which is a table that transforms the form of the data. I have used a Pivot Table extensively in many systems to convert data from a normalized form to a de-normalized form. However, this week I have found a new use for a Pivot Table. I have found that the Pivot Table can be used to transform data in the opposite manner from a de-normalized form into a normalized form much more efficiently than any other method available. This article reviews the normalization of de-normalized data using a pivot table.

 Read this article...

 Related Articles - For Members.
All Articles By Author

Using SQL Server Joins
Second Normal Form (2NF)
Nulls, Plain and Simple
Migrating from Oracle to SQL Server 2000 Part –I
From xp_sendmail to safe_sendmail
Debugging/Tuning Your PL/SQL With Dbms_trace
Modeling Hierarchical Relationships: Schema Management Tools
SQL Server 6.5: Some useful undocumented DBCC commands
SQL Server 2000 useful undocumented stored procedures



Key (Please note):
(R) - registration may be required for access at the target site
($) - target site may require paid membership for access to this or other content


No Comments/Feedback Posted Yet. Post Your Comments/Feedback

Email to Friend //  Discuss Article //  Rate Article //  Digg Article //  Add to Del.icio.us //  Add to Technorati

   




 

[ Register ] [ Webcasts ] [ Podcasts ] [ Newsletter Archive ] [ RSS/Feeds ]
[ About ] [ Advertise ] [ Contact ] [ Privacy ] [ Terms of Service ]
[ Link to SSWUG ] [ List Server Archives ] [ Recent Orig. Content ]
(c) 1997-2008, Bits on the Wire, Inc.  (0)

Some names and products covered by SSWUG are the registered trademarks of their respective owners.
DAA10354WWW004