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 |
|
koolnkool
Starting Member
9 Posts |
Posted - 2009-10-30 : 06:04:58
|
| hi,i have a table with 500 records approximately.my requirement is that from front end i will get a number. based on that number,i need to display the data of a row in that table.i.e if i get 14 i need to display 14th row data only in o/p.how can i achieve it in a sql query? |
|
|
ashishashish
Constraint Violating Yak Guru
408 Posts |
Posted - 2009-10-30 : 06:06:48
|
| ;with CTE as( select * ,row_number() over(order by yourcolumn) as RN from yourtable)select * from CTE where Rn=yourfrontendvalueiF theRe iS a wAy iN tHen theRe iS a wAy oUt.. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-10-30 : 06:06:54
|
ordered by what? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
koolnkool
Starting Member
9 Posts |
Posted - 2009-10-30 : 06:10:18
|
| i dont need order by, becoz i dont want to rearrange o/p |
 |
|
|
ashishashish
Constraint Violating Yak Guru
408 Posts |
Posted - 2009-10-30 : 06:10:27
|
| ORSelect * from ( select * ,row_number() over (order by yourvalue) as RN from yourtable)t where t.RN=yourfrontendvalueThis will also workiF theRe iS a wAy iN tHen theRe iS a wAy oUt.. |
 |
|
|
koolnkool
Starting Member
9 Posts |
Posted - 2009-10-30 : 06:11:23
|
| i need to extract the row from the existing data only. i mean i want 1th row from top in the existing data only |
 |
|
|
ashishashish
Constraint Violating Yak Guru
408 Posts |
Posted - 2009-10-30 : 06:23:56
|
quote: Originally posted by koolnkool i need to extract the row from the existing data only. i mean i want 1th row from top in the existing data only
Show us some sample data and expected output...iF theRe iS a wAy iN tHen theRe iS a wAy oUt.. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-10-30 : 06:25:49
|
SQL Server tables have no reliable order of records.Hence you cannot retrieve the nth row without having a column that gives you an order of rows in table! No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|