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

Convert rows to columns Expand / Collapse
Author
Message
Posted Tuesday, November 27, 2012 8:10 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, June 04, 2013 6:44 PM
Points: 46, Visits: 72
We have a following table:
[Day] [Time]
Mon 07:00
Tue 12:00
Mon 10:00
Mon 15:00
Tue 15:00
Tue 20:00
I want to make a query in sql 2005 to have the following result:
07:00 10:00 12:00 15:00 20:00
Mon Mon Tue Mon Tue
NULL NULL NULL Tue NULL

Please help me do it?
Thank you very much!
Post #1389487
Posted Tuesday, November 27, 2012 8:40 PM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Yesterday @ 8:26 PM
Points: 500, Visits: 2,292
Edit: I misunderstood your question... What's with the NULLS?

-- Alan Burstein



Read this article for best practices on asking questions.
Need to split a string? Try this (Jeff Moden)
Need a pattern-based string spitter? Try this (Dwain Camps)
My blog
Post #1389488
Posted Tuesday, November 27, 2012 9:38 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 12:11 AM
Points: 223, Visits: 429
seems this Cross Tab Procedure will help your to solve this issue
Post #1389500
Posted Tuesday, November 27, 2012 9:39 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, February 18, 2013 1:47 AM
Points: 196, Visits: 87
Your Question is not clear.
Post #1389501
Posted Wednesday, November 28, 2012 8:32 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 3:28 PM
Points: 12,034, Visits: 11,062
goodtomorrow01 (11/27/2012)
We have a following table:
[Day] [Time]
Mon 07:00
Tue 12:00
Mon 10:00
Mon 15:00
Tue 15:00
Tue 20:00
I want to make a query in sql 2005 to have the following result:
07:00 10:00 12:00 15:00 20:00
Mon Mon Tue Mon Tue
NULL NULL NULL Tue NULL

Please help me do it?
Thank you very much!


Nobody can help you because you didn't provide enough details for somebody to help. Please see the first link in my signature for best practices when posting a question.


_______________________________________________________________

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 #1389837
Posted Thursday, November 29, 2012 12:31 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, June 04, 2013 6:44 PM
Points: 46, Visits: 72
Thank you very much for interested in my question. However, I find out answer from here : http://social.msdn.microsoft.com/Forums/en/transactsql/thread/07dd8fb0-4c2c-4ed0-a6a6-4ca6a488f2d0
Again, thanks anyway and hope continue getting your help for next time.
Post #1390316
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse