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 |
|
aoriju
Posting Yak Master
156 Posts |
Posted - 2009-07-30 : 09:28:06
|
| DECLARE @tbl_test AS TABLE(ID INT,PNAME VARCHAR(20))INSERT INTO @tbl_Test(ID,PNAME) VALUES(1,'RIJU')INSERT INTO @tbl_Test(ID,PNAME) VALUES(2,'SENIL')INSERT INTO @tbl_Test(ID,PNAME) VALUES(1,'ANOOP')INSERT INTO @tbl_Test(ID,PNAME) VALUES(1,'SAJIN')INSERT INTO @tbl_Test(ID,PNAME) VALUES(3,'ANTONY')INSERT INTO @tbl_Test(ID,PNAME) VALUES(3,'ABDU')I want to Get Sl No as 1,2,3 for RIJU,ANOOP,SAJIN1 FOR SENIL1,2 FOR ANTONY,ABDU |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-30 : 09:37:37
|
[code]select *, SNo = row_number() over (partition by ID order by PNAME)from @tbl_test[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|
|