November 27, 2012 at 8:10 pm
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!
November 27, 2012 at 8:40 pm
Edit: I misunderstood your question... What's with the NULLS?
-- Itzik Ben-Gan 2001
November 27, 2012 at 9:38 pm
seems this Cross Tab Procedure[/url] will help your to solve this issue
Every rule in a world of bits and bytes, can be bend or eventually be broken
MyBlog About Common dialog control
A Visualizer for viewing SqlCommand object script [/url]
November 27, 2012 at 9:39 pm
Your Question is not clear.
November 28, 2012 at 8:32 am
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 Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
November 29, 2012 at 12:31 am
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.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply