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 |
|
rameshsri
Starting Member
2 Posts |
Posted - 2011-06-22 : 07:41:02
|
| Hi, I am adding one name tableId Name Age Address1 gokul 25 bigst2 srikanth 27 bigst3 imran 25 bigst4 karthick 30 bigst5 sathish 25 bigst now i am creating one selected sp which is who are all in age 25 so the result isId Name Age Address1 gokul 25 bigst3 imran 25 bigst5 sathish 25 bigstIt executes fine but i want there is 3 names out of 5 names the result is should be printed like this Id Name Age Address SNO1 gokul 25 bigst 13 imran 25 bigst 25 sathish 25 bigst 3So i want one more column so display the serial no i dont know how it doneRamesh Srinivasan |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-06-22 : 07:49:17
|
If you are on SQL 2005 or higher, you can do this using the row_number() function. You would add a column to your query, something like this:row_number() over(order by Id) as SNO |
 |
|
|
raghuveer125
Constraint Violating Yak Guru
285 Posts |
Posted - 2011-06-22 : 07:49:25
|
| which version you are using ?In Love... With Me! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|