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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 query where results must be displayed as columns.

Author  Topic 

radhe
Starting Member

6 Posts

Posted - 2007-12-27 : 08:04:01
I want to get a query where the rows must be displayed as columns.

eg:
===

select * from numbers
=================

Numbers

one
Two
Three
four

For me it must display as:

Numbers one Two Three four

please tell me a query to do that

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-27 : 08:19:33
Do you want to have 1 million columns if there are same number of rows?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

radhe
Starting Member

6 Posts

Posted - 2007-12-27 : 08:36:18
No I want to have only 12 columns which represent 12 months ok
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2007-12-27 : 09:14:43
Can you give struture of your table?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-12-27 : 21:42:51
quote:
Originally posted by radhe

No I want to have only 12 columns which represent 12 months ok



just use case when

case number when 1 then 'one' when 2 then 'two' . . . .



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -