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
Can variables be used in sql statements?
GLOBAL TEMPORARY TABLE over Views in advantages insolving mutating error?
What is the largest value that can be stored in a byte data field?
C. Normalize the following data up to the 3rd Normal form. Create the tables and insert the data given. Emp_ID Name Dept_Name Salary Course_Title Date_Completed 100 Adam Marketing 48,000 SPSS 6/19/2008 Surveys 10/7/2008 140 Bob Accounting 52,000 Tax Acc 12/8/2008 110 Cathy IT SQL Server 1/12/2008 C# 4/22/2008 190 Dan Finance 150 Emily Marketing 55,000 SPSS 6/16/2008 42,000 Analysis 8/12/2008 Queries 1. Find all Names who have completed the SPSS Course. 2. Find employee with max salary. 3. Find employee with 2nd max salary. 4. Find all employees in Dept “Marketing”. 5. Find all the employees who have taken more than 2 courses. 6. Find all the employees who have completed the courses before month of September.
What is the use of non clustered index?
What is the difference between truncate and drop statements?
what are the differences between get and post methods in form submitting. Give the case where we can use get and we can use post methods? : Sql dba
What is sql rowcount?
When do we use triggers?
what are the differences between char and nchar? : Sql dba
How much does sqlite cost?
What does trigger mean in psychology?
what is acid property in database? : Sql dba
Name the operator which is used in the query for pattern matching?
Explain the significance of the & and && operators in pl sql.