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
 Help Query

Author  Topic 

anil.murakonda
Starting Member

4 Posts

Posted - 2011-04-20 : 04:37:52
My Table is
Empno Ename
1 Anil
2 Ravi
1 Kumar
2 Kumar


I want to display like this

empno ename
1 Anil,Kumar
2 Ravi,Kumar

how o write query Above o/p....?



Anilchow..

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2011-04-20 : 05:03:57
Refer this -
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=159359

Vaibhav T

If I cant go back, I want to go fast...
Go to Top of Page

raghuveer125
Constraint Violating Yak Guru

285 Posts

Posted - 2011-04-20 : 05:18:15
In this Kumar is fixed for all name?

Raghu' S
Go to Top of Page

raghuveer125
Constraint Violating Yak Guru

285 Posts

Posted - 2011-04-20 : 05:21:34
declare @t table (id int , Fname nvarchar(25))
insert into @t
select 1,'Anil' union all
select 2,'Ravi' Union all
select 1,'Kumar' union all
select 2,'Kumar'


Select a.id,a.Fname+' '+b.Fname from @t
as a left outer join @t as b on b.id=a.id
where a.id=b.id and a.Fname<>b.Fname and b.Fname like ('%Kumar')

Raghu' S
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-04-20 : 05:58:11
quote:
Originally posted by anil.murakonda

My Table is
Empno Ename
1 Anil
2 Ravi
1 Kumar
2 Kumar

I want to display like this

empno ename
1 Anil,Kumar
2 Ravi,Kumar

how o write query Above o/p....?

Anilchow..



How do you determine the sequence ?
example : 'Ravi, Kumar' and not 'Kumar, Ravi' ?


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

Go to Top of Page
   

- Advertisement -