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

Can i do this (pivot) Expand / Collapse
Author
Message
Posted Tuesday, February 11, 2014 1:13 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, September 12, 2014 4:50 AM
Points: 78, Visits: 448
Im not even sure this is possible.

I have a data set that is pulled into a excel spread sheet and pivoted as below.




orders and values are group along the top for currency (GBP), Code (E), Group (Austin), Year(2010), Month (10) and split by sales date (row labels). obviously there are many different groups, codes, year, month which stretch along the top.

im wanting to replicate this into a staging table, is this possible. i looked at pivot but it only seems to work with one grouping?

all help appreciated
Post #1540423
Posted Tuesday, February 11, 2014 1:20 PM


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 @ 7:21 PM
Points: 3,645, Visits: 7,961
It's possible, take a look at this articles:
Cross Tabs: Part 1
Cross Tabs: Part 2



Luis C.
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?

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1540426
Posted Tuesday, February 11, 2014 2:51 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, September 12, 2014 4:50 AM
Points: 78, Visits: 448
i had a look, im not sure if this will give me the ability to dybamicaly build the column groupings. or am i missing somthing - possible
Post #1540459
Posted Tuesday, February 11, 2014 4:20 PM


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 @ 7:21 PM
Points: 3,645, Visits: 7,961
I'm not sure what you need without DDL, sample data and expected results.
However, those articles have the basic theory to pivot queries both static and dynamic.

For more help, please read the article linked on my signature.



Luis C.
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?

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

Add to briefcase

Permissions Expand / Collapse