how to retrieve the top 3 salaries of the table using rownum
Answer Posted / d.elumalai
CREATE TABLE EMP (NAME VARCHAR2(20),SALARY NUMBER(10));
INSERT INTO EMP VALUES('AAA',10000);
INSERT INTO EMP VALUES('BBB',20000);
INSERT INTO EMP VALUES('CCC',30000);
INSERT INTO EMP VALUES('DDD',40000);
INSERT INTO EMP VALUES('EEE',50000);
INSERT INTO EMP VALUES('FFF',60000);
INSERT INTO EMP VALUES('GGG',70000);
INSERT INTO EMP VALUES('HHH',80000);
INSERT INTO EMP VALUES('III',90000);
COMMIT;
SELECT A.* FROM (SELECT name, salary FROM EMP ORDER BY salary DESC) A WHERE ROWNUM<=3;
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Which sorts rows in sql?
Where is pl sql used?
What are sql queries used for?
how to create a new view in mysql? : Sql dba
What is the use of triggers?
What is sqlerrd?
What does <> sql mean?
What is a .db file?
Can we perform dml in function?
Is sql open source?
What is a scalar value in sql?
What is a sql trace file?
What are schema-level triggers?
What is aggregate function in sql?
Can a primary key be a foreign key?