Which two statements will return the names of the three employees with the lowest salaries? (Choose two.)
Which two statements will return the names of the three employees with the lowest salaries? (Choose two.)
To return the names of the three employees with the lowest salaries, the query needs to first order the employees by salary in ascending order and then limit the results to the first three. Option B uses an inline view to order by salaries and then uses rownum to limit the results, which achieves the desired outcome. Option C orders the employees by salary and then uses FETCH FIRST 3 ROWS ONLY to limit the results, which also works correctly. Therefore, options B and C are the correct choices for this query.
A. select last_name, salary from employees fetch first 3 rows only order by salary; - results in an error --------------------------------------------- B. select last_name, salary from ( select * from employees order by salary) where rownum <= 3; - works ------------------------------------------------------- c. select last_name, salary from employees order by salary fetch first 3 rows only ; - works ---------------------------------------------------------------- D. select last_name, salary from employees where rownum <= 3 order by salary; - returns the first 3 rows and orders the 3 rows based on salary so its incorrect ------------------------------------------------------- E. select last_name, salary from employees where rownum <= 3 order by (select salary from employees); - subquery returns more than one row so results in error
thx, u made me facepalm cuz I forgot that, thx again 4 help
D is wrong after order by rownum might not anymore be sequential.
D is the correct answer