SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


guidence concerning pivot table


guidence concerning pivot table

Author
Message
bryan van ritter
bryan van ritter
SSC-Enthusiastic
SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)

Group: General Forum Members
Points: 166 Visits: 513
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
Sean Lange
Sean Lange
One Orange Chip
One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)

Group: General Forum Members
Points: 25853 Visits: 17509
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 Modens 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)
bryan van ritter
bryan van ritter
SSC-Enthusiastic
SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)

Group: General Forum Members
Points: 166 Visits: 513
solved the problem myselve.
bryan
Lynn Pettis
Lynn Pettis
SSC-Dedicated
SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)

Group: General Forum Members
Points: 38977 Visits: 38508
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.

Cool
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)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search