Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

PIVOT more than two columns Expand / Collapse
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.

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



Group: General Forum Members
Last Login: Today @ 10:06 AM
Points: 7,486, Visits: 16,246
You could easily use CROSS TABS to pivot your data.
Read the following article and come back if you need extra help.

Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

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

Add to briefcase

Permissions Expand / Collapse