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.
| Author |
Topic |
|
bhu
Starting Member
1 Post |
Posted - 2003-06-04 : 20:07:40
|
| Hi alli have a scenario like thisTable A:ID Name Salarythree column where ID is the auto increment and primary key fieldThe data entered are like thisID Name Salary1 aaa 10002 aaa 20003 aaa 30004 bbb 3000i want the result containing only one row in case if the name is repeated many timesIn other wordsi like my output to be1 aaa 10004 bbb 3000how do u go about it?thanks in advance |
|
|
chadmat
The Chadinator
1974 Posts |
Posted - 2003-06-04 : 20:21:01
|
| use tempdbcreate table #t1(ID int, Name varchar(3), Salary int) insert into #t1 values(1, 'aaa', 1000) insert into #t1 values(2, 'aaa', 2000) insert into #t1 values(3, 'aaa', 3000) insert into #t1 values(4, 'bbb', 3000) select a.ID, a.Name, a.Salary from #t1 ajoin (select min(ID) ID, Name from #t1 group by Name) bon a.ID=b.ID-Chadhttp://www.clrsoft.comSoftware built for the Common Language Runtime. |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2003-06-04 : 20:21:44
|
| How do decide which of the 3 rows you want to display ?Damian |
 |
|
|
|
|
|