Solved

When can I use PIVOT and when should I use UNPIVOT?I

Posted on 2014-01-23
1
221 Views
Last Modified: 2014-01-24
Can anyone please tell me when I should be using PIVOT and when I should be using UNPIVOT?
0
Comment
Question by:RajG1978
1 Comment
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
Comment Utility
If you receive a normalized table, you can use PIVOT (scroll down for some examples) to change it so that it is pivoted, i.e. rows-columns-value, like an Excel spreadsheet.

If you receive PIVOTED data, and wish to normalize it, that would be an UNPIVOT.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now