how to retrieve last tree records from table?
select *from emp where rownum > (select count(*)-3 from
emp);
i am using this query to get last three records from table
but its not giving any output, so please tell me what is the
error in this query.
Answers were Sorted based on User's Feedback
Answer / ajit nayak
select *from emp
minus
select *
from emp
where rownum <= (select count(*)-3 from
emp);
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / swastik
SELECT * FROM
(
SELECT * FROM Emp
ORDER BY ROWNUM DESC
)
WHERE ROWNUM <= 3;
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ashwin
if emp table is having 10 records then
1)for first 6 write
select ename,sal from(select ename,sal from emp order by sal
desc) where rownum <7;
2)for last 3 write
select ename,sal from(select ename,sal from emp order by sal
desc) where rownum >7;
| Is This Answer Correct ? | 2 Yes | 3 No |
Answer / shekaran04
Hi,
First thing you cannot use " ROWNUM > (somthing) "
And to get last three records...
Select *from emp
minus
Select *from emp where rownum <(select Count(*) from emp)-
3;
Good Luck...
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / mohammed shahid
select distinct TOP3 from emp order by rownum desc;
| Is This Answer Correct ? | 2 Yes | 8 No |
How many types of relationship are there?
How can you create an empty table from an existing table?
how view used for security purposes?
What is cost in sql execution plan?
What is cursor explain with example?
How do I remove sql developer from windows 10?
Whate is use of MOD function in pl/sql.
How do you select unique values in sql?
Hello All, Could any well write a query for the following scenario. Account(table name) No Name Amount 1 ABCD 2000.00 2 DEFG -2000.00 3 GHIJ 3000.50 4 JKLM 4000.00 5 MNOP 6000.00 O/p Should be in this format No Name Credit Debit 1 ABCD 2000.00 0 2 DEFG 0 -2000.00 3 GHIJ 3000.50 4 JKLM 0 -4000.00 5 MNOP 6000.00 o could any one give appropriate query for this Thnks in Advance
Can we use more than one null value for unique key?
31 Answers A1 Technology, Wipro,
what is a table called, if it has neither cluster nor non-cluster index? What is it used for? : Sql dba
how can we destroy the session, how can we unset the variable of a session? : Sql dba
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)