How to select nth record from a table?
Answers were Sorted based on User's Feedback
Answer / ravinder pawar
Hi Frnds,
Pravin's logic is correct. I am just modifying it little
bit.
Select Top 1 *
From (Select Top 5 *
from HumanResources.Employee
order by EmployeeID desc)as temp
---Note If we don't use temp we'll get error as mentioned
below:
Incorrect syntax near ')'.
| Is This Answer Correct ? | 0 Yes | 2 No |
Answer / pravin s. ahire
Select Top 1 *
From (Select Top N * from tablename order by
table.ColumnName desc)
-- where N = nth record
| Is This Answer Correct ? | 0 Yes | 3 No |
Answer / sajida
--For ex in dept table to select 5th record. Instead of
this you can use &n so that it can ask row number
select rnum, d.* from dept d, (select rownum rnum ,
deptno from dept ) e
where d.deptno = e.deptno and rnum = 5
| Is This Answer Correct ? | 5 Yes | 10 No |
How to enforce security in sql server? : sql server security
What is the minimum and maximum number of partitions required for a measure group? : sql server analysis services, ssas
Explain contrast amongst grouped and non-bunched records?
What is difference between sql and sql server?
When you first load SQL SERVER you will startup with what all databases?
What is database isolation in sql server? : sql server database administration
How to update values in a table with update statements in ms sql server?
How to recreate an existing index in ms sql server?
What is not null constraint?
How to create a view and a stored procedure in ms sql server using "create view/procedure" statements?
How to delete duplicate rows?
How to rebuild indexes with alter index ... Rebuild?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)