how to retrive only second row from table in sql server
2000?
Answers were Sorted based on User's Feedback
Answer / dileep.t
----------------------------------
:), This will also work, without additional columns in
result
---------------------------------
DECLARE curTemp SCROLL CURSOR FOR
SELECT TOP 2 * from <TABLE_NAME>
OPEN curTemp
FETCH LAST FROM curTemp
CLOSE curTemp
DEALLOCATE curTemp
| Is This Answer Correct ? | 12 Yes | 2 No |
Answer / suresh
Hi,
select top 1 * from (SELECT TOP 2 * from emp) A Order by
empno desc
| Is This Answer Correct ? | 16 Yes | 9 No |
Answer / yogesh
select top 1 from tablename where id <(select top 1 id from
test)
| Is This Answer Correct ? | 5 Yes | 0 No |
Answer / arun kumar k s
drop table #temp select top 2 identity(int,1,1) as SlNo, *
into #temp from TABLE_NAME select * from #temp where SlNo=2
| Is This Answer Correct ? | 7 Yes | 5 No |
Answer / ravi148
hi,
dileep is exactly correct , arun .. iam sorry to say ur
wrong
suppose for employee table, write as
DECLARE curTemp SCROLL CURSOR FOR
SELECT TOP 2 * from EMPLOYEE
OPEN curTemp
FETCH LAST FROM curTemp
CLOSE curTemp
DEALLOCATE curTemp
| Is This Answer Correct ? | 4 Yes | 2 No |
Answer / shashikant
select min(id) from cms_dfm where id in (SELECT TOP 2 ID
from CMS_DFM Order by
ID desc)
| Is This Answer Correct ? | 6 Yes | 4 No |
Answer / belson gnana pradeep
SELECT TOP 1 salary FROM
(SELECT DISTINCT TOP 2 salary FROM employee
ORDER BY salary DESC) a ORDER BY salary
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / vardharaj
SELECT TOP 1 ID FROM TABLENAME WHERE ID NOT IN (SELECT TOP 1
ID FROM TEST)
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / surenda tarai
select top 1 * from(select top 3 * from tablename order by 1
asc) as at order by 1 desc
| Is This Answer Correct ? | 1 Yes | 0 No |
Is Sql non procedural query language?
How to fetch the next row from a cursor with a "fetch" statement?
What is blocking and how would you troubleshoot it?
how to get 25th row in any table in sqlserver can u tell me syntax
Hi, I have a table A which has four rows as follows Table A ------- empname salary ------- ------ A 1000 B 2000 C 3000 A 1000 B 2000 D 5000 I need the following output: empname salary ------- ------ A 1000 A 1000 B 2000 B 2000 Thanks in advance
What is wrong with sql server client libarary dll, ntwdblib.dll?
What are the differences between having and where clause.
In what three ways is the return statement used in a stored procedure?
How to delete database objects with "drop" statements in ms sql server?
How to list all stored procedures in the current database using ms sql server?
What is local temp table?
i want only duplicates rows from coloumn ex. emp_id(colomn name)1,1,2,3,3,4,5,5. so i want only duplicates no.
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)