You want to display 5 percent of the employees with the highest salaries in the
EMPLOYEES table. Which query will generate the required result?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
You want to display 5 percent of the employees with the highest salaries in the
EMPLOYEES table. Which query will generate the required result?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
B is correct! The key word first is necessary.
B
The syntax for the row limiting clause:
FETCH { FIRST | NEXT } [ { rowcount | percent PERCENT } ]
{ ROW | ROWS } { ONLY | WITH TIES } ]
D
Top-N Queries
The syntax for the row limiting clause looks a little complicated at first glance.
[ OFFSET offset { ROW | ROWS } ]
[ FETCH { FIRST | NEXT } [ { rowcount | percent PERCENT } ]
{ ROW | ROWS } { ONLY | WITH TIES } ]
Letter B is the right answer
SQL> select employee_id,last_name,salary from employees
2 order by salary desc
3 fetch first 5 percent rows only;
EMPLOYEE_ID LAST_NAME SALARY
———– ————————- ———-
100 King 24000
203 Mavris 24000
101 Kochhar 17000
102 De Haan 17000
145 Russell 14000
146 Partners 13500
6 rows selected.
SQL>