Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Row into Column

Author  Topic 

ck.keerthi
Starting Member

3 Posts

Posted - 2009-09-03 : 10:09:49
Hi all,
I have a table like this ..

Project Date Hours
----- ---- -----
A 1 8
A 2 8
B 3 8
C 4 8
D 5 8

If table is queried , I need like ..


Date 1 2 3 4 5
Project A B C D E
Hours 8 8 8 8 8

Can anyone help me on this issue ? or if you find any link explaining what i need kindly post asap ..!


Keerthi C

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-09-03 : 10:12:43
If it is SQL 2005 or above, use PIVOT, if it is SQL 2000, then you will need to use temp tables as far as I remember.
Go to Top of Page

ck.keerthi
Starting Member

3 Posts

Posted - 2009-09-03 : 10:23:08
Hi RickD,

Thank you for quick response. I am working on sql 2005 .

if you have any sample queries can you post it ?

It will be helpful for me as well as future people who refer this forums :)

Thanks,
Expecting sample query ,
Keerthi C

Keerthi C
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-09-03 : 10:37:00
Why not look at Books Online, there are examples in there?

http://msdn.microsoft.com/en-us/library/ms177410.aspx
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2009-09-03 : 10:37:08
If you search the forums for PIVOT, you will see many examples of how to use it.

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

ck.keerthi
Starting Member

3 Posts

Posted - 2009-09-03 : 10:47:39
Thanks All But I too Found a link which says whats i need exactly :)

http://www.sqlsnippets.com/en/topic-12180.html

Enjoy. ..!! Thanks ALL ..!!

Happy Coding ..!!

Keerthi C
Go to Top of Page
   

- Advertisement -