Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

PIVOT more than two columns Expand / Collapse
Author
Message
Posted Tuesday, July 15, 2014 2:12 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, July 15, 2014 2:06 AM
Points: 1, Visits: 0
I have data as below in a table

Region Transactions Production Value
EAST Sales LUX 1000
EAST Sales Cinthol 1500
EAST Purchases LUX 1000
EAST Purchases Cinthol 1500
NORTH Sales LUX 3000
NORTH Sales Cinthol 3500
NORTH Purchases LUX 3000
NORTH Purchases Cinthol 3500
SOUTH Sales LUX 4000
SOUTH Sales Cinthol 4500
SOUTH Purchases LUX 4000
SOUTH Purchases Cinthol 4500
WEST Sales LUX 2000
WEST Sales Cinthol 2500
WEST Purchases LUX 2000
WEST Purchases Cinthol 2500


I want a query to get the data as below.

LUX CINTHOL
Region SALES PURCHASES SALES PURCHASES
EAST 1000 1000 1500 1500
WEST 2000 2000 2500 2500
NORTH 3000 3000 3500 3500
SOUTH 4000 4000 4500 4500
Post #1592443
Posted Tuesday, July 15, 2014 8:25 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 6:07 PM
Points: 3,313, Visits: 7,150
You could easily use CROSS TABS to pivot your data.
Read the following article and come back if you need extra help.
http://www.sqlservercentral.com/articles/T-SQL/63681/



Luis C.
I am a great believer in luck, and I find the harder I work the more I have of it. Stephen Leacock

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1592606
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse