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

guidence concerning pivot table Expand / Collapse
Author
Message
Posted Friday, March 29, 2013 1:40 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: 2 days ago @ 6:44 AM
Points: 87, Visits: 465
Hi,

i have a table which looks like this:

custid item date amount
1 3 1-1-2013 1
1 2 1-1-2013 2
2 4 1-2-2013 2
2 4 1-2-2013 1

and i want to make it look like this:

date item1 item2 item3
1-1-2013
custid
1 2 0 1
1 3 1 1
1 4 1 1
1-2-2013
custid
2 5 1 1
2 1 1 1
2 4 1 1

can anyone help me with some guidence on this

thanx in advance,

regards,
bryan
Post #1437077
Posted Friday, March 29, 2013 2:15 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 2:05 PM
Points: 11,927, Visits: 10,967
bryan van ritter (3/29/2013)
Hi,

i have a table which looks like this:

custid item date amount
1 3 1-1-2013 1
1 2 1-1-2013 2
2 4 1-2-2013 2
2 4 1-2-2013 1

and i want to make it look like this:

date item1 item2 item3
1-1-2013
custid
1 2 0 1
1 3 1 1
1 4 1 1
1-2-2013
custid
2 5 1 1
2 1 1 1
2 4 1 1

can anyone help me with some guidence on this

thanx in advance,

regards,
bryan


I would recommend you take a few minutes and read the article found at the first link in my signature. It explains the best practices for posting questions. If you post ddl, sample data and desired output like in that article you will have lots of people jumping on your issue and you will get an answer very quickly.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1437091
Posted Sunday, March 31, 2013 1:36 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: 2 days ago @ 6:44 AM
Points: 87, Visits: 465
solved the problem myselve.
bryan
Post #1437323
Posted Sunday, March 31, 2013 3:43 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 9:47 PM
Points: 22,472, Visits: 30,138
bryan van ritter (3/31/2013)
solved the problem myselve.
bryan


Great! That is good news. Now, forum etiquette would have you post your solution as it may benefit others with a similar problem or issue.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1437336
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse