QuestionQ255

VerifiedReporting Aggregated Data Using the Group Functions

Review the description of the EMPLOYEES table:

Question Image

Review these requirements:

  1. Show the manager ID and the salary of the lowest-paid employee for that manager.
  2. Exclude employees whose manager is unknown.
  3. Exclude managers whose minimum salary is 6000 or less.
  4. Order the results by minimum salary, with the highest salary first.

Which statement accomplishes this?

Explanation

GROUP BY manager_id creates one group for each manager and MIN(salary) returns that group’s lowest salary. WHERE manager_id IS NOT NULL removes rows with an unknown manager before grouping. HAVING MIN(salary) > 6000 filters groups by their computed minimum salary, and ORDER BY MIN(salary) DESC sorts those minimum values from highest to lowest. Oracle documents that aggregate functions can be used in HAVING and ORDER BY, and that HAVING restricts grouped results.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!