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 Help--I need to Pivot really to just make the rows the column Expand / Collapse
Author
Message
Posted Tuesday, September 10, 2013 9:39 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, September 11, 2013 11:51 AM
Points: 97, Visits: 363
SELECT CONVERT(varchar,C.SCHED_DTTM,101) as DATE,C.INV_ITEM_ID ,SUM(C.QTY_REQUESTED) AS QTY
FROM PS_IN_DEMAND C WHERE C.SCHED_DTTM>=GETDATE() AND C.IN_FULFILL_STATE IN (10,20,30,40)
GROUP BY C.SCHED_DTTM,C.INV_ITEM_ID
ORDER BY C.SCHED_DTTM,C.INV_ITEM_ID

DATE INV_ITEM_ID QTY
9/10/2013 W526R 2
9/10/2013 X426R 1
9/10/2013 6414 3
9/11/2013 2001-1 4
9/11/2013 2001-2 4
9/11/2013 2001-5 4
9/11/2013 10-1109R 1
9/12/2013 12401 1
9/12/2013 12402 1
9/12/2013 12405 1
9/12/2013 12406 1
9/12/2013 12433 1
9/12/2013 3801 1

Post #1493263
Posted Tuesday, September 10, 2013 9:43 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 @ 10:52 PM
Points: 3,476, Visits: 7,514
You're not giving enough information.
We would be happy to help but we need you to be more explicit on what you need.
Please post the DDL for your tables and sample data in the form of INSERT statements, as well as the expected results based on that sample data.



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 #1493265
Posted Wednesday, September 11, 2013 7:33 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 12:51 PM
Points: 11,199, Visits: 12,959
Take a look at the Cross Tab and Pivot links in my signature. I think they'll give you what you need.



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #1493676
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse