Home > database >  SQL * PLUS for help: for the highest paid sixth to tenth employees
SQL * PLUS for help: for the highest paid sixth to tenth employees

Time:10-23

Strives for the highest paid sixth to tenth employees

CodePudding user response:

Select *
The from (select t. *, rownum asd from table name t order by desc) salary a
Where a.a sd between 6 and 10;

CodePudding user response:

 
Select * from
(
Select *
From the employee
The order by the sales des
) where rownum between 6 and 10

Have a try

CodePudding user response:

 
Select ename, sal from
(
Select ename, sal, rownum r from
(select ename, sal from emp order by sal desc)
)
Where r>=6 and r<=10
;

CodePudding user response:

You can use the row_number function, so it is ok to write two layers of the select,

CodePudding user response:

Idea is: use a subquery to get ranked first, and then their query set ranking condition
Select *
The from (select t. *, rownum asd from table name t order by desc) salary a
Where a.a sd between 6 and 10;

CodePudding user response:

Row_number over rather than rownum the landlord to take note

CodePudding user response:

You guys, this is the oracle is really convenient,

CodePudding user response:

Select * from
(
Select *
From the employee
The order by the sales des
) where rownum between 6 and 10

CodePudding user response:

Specific statements don't write, say a train of thought, the staff table according to the salary in descending order, return to the employee information and rownum, then check the result of the above set of 6 to 10

CodePudding user response:

Select * from
(select name, sal, row_number () over (order by sal desc) as ro)
Where ro between 6 and 10;

CodePudding user response:

 select * from 
(select name, sal, row_number () over (order by sal desc) as ro from emp)
Where ro between 6 and 10;
  • Related