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
 SQL Server Development (2000)
 Converting rows into columns

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-05-11 : 07:32:47
mukundhan writes "Hi,

I need to fetch a value from a table which will return some 4-5 records and i need that as a single row with as much as columns.

say,
********table1
id name
-------
01 sales
02 date
03 status

********table2
value empid id
--------------
x 0001 01
xx 0001 02
xxx 0001 03

if i try to fetch the value from table2 where empid=0001 then i'll be having 3 records but my output should look like

empid sales date status
-----------------------
0001 x xx xxx

Thanks,
Mukundhan.S"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-05-11 : 07:33:42
You need a cross tab, try this:

http://weblogs.sqlteam.com/jeffs/archive/2005/05/02/4842.aspx
Go to Top of Page
   

- Advertisement -