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)
 Help Please

Author  Topic 

ragh
Starting Member

34 Posts

Posted - 2004-07-10 : 02:34:39
Hello There !

I have some records like
231 george
231 Peter
231 sam
231 mike
251 daisy
251 linda

I want to get a result set like

231 george
Peter
sam
mike
251 daisy
linda

here is the table design

Create table temp (id Int Identity(1,1), identifier Int, Name Varchar(30))
Insert into Temp(identifier, Name) values (231, 'george')
Insert into Temp(identifier, Name) values (231,'Peter')
Insert into Temp(identifier, Name) values (231, 'sam')
Insert into Temp(identifier, Name) values (231, 'mike')
Insert into Temp(identifier, Name) values (251, 'daisy')
Insert into Temp(identifier, Name) values (251, 'linda')

Can someone please help me with a query....

adios

Ragh

Kristen
Test

22859 Posts

Posted - 2004-07-10 : 02:58:54
[code]
SELECT CASE WHEN EXISTS
(
SELECT *
FROM TEMP T2
WHERE T2.identifier = T1.identifier
AND T2.id < T1.id
) THEN ''
ELSE CONVERT(varchar(20), T1.identifier) + ' '
END
+ Name
FROM TEMP T1
ORDER BY T1.identifier, T1.id
[/code]
Go to Top of Page
   

- Advertisement -