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 |
|
MageshkumarM
Yak Posting Veteran
61 Posts |
Posted - 2011-01-04 : 00:23:23
|
| Hi,I have one query to find the row,for example i have 1000 Rows in a table,i need to find row no. 425. using single line query.can anyone help me out of this..Regards,MAGSQL newer |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-01-04 : 00:46:14
|
[code]select * from (select *, row_no = row_number() over (order by somecol) from yourtable ) d where d.row_no = 425[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2011-01-04 : 00:48:50
|
| MAG, you can use the row number function in order to assign numbers to the result set. e.g.create a procedure which returns the result set with row numbers and having a parameter e.g. exec abc 425The parameter will be used in the where clause over the "row number" column ...Cheers!MIK |
 |
|
|
MageshkumarM
Yak Posting Veteran
61 Posts |
Posted - 2011-01-04 : 01:06:27
|
| ya i found the row which is i looking and thk u guys..Regards,MAGSQL newer |
 |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2011-01-04 : 02:27:54
|
| Rows have no intrinsic order. If you say you want row no 425, you need to also say which column you're ordering by to get that value. Tables are unordered sets of data and SQL does not keep a record of insert order.--Gail ShawSQL Server MVP |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|