nerdexam
Oracle

1Z0-007 · Question #146

Evaluate the SQL statement: 1 SELECT a.emp_name, a.sal, a.dept_id, b.maxsal 2 FROM employees a, 3 (SELECT dept_id, MAX(sal) maxsal 4. FROM employees 5. GROUP BY dept_id) b 6. WHERE a.dept_id =…

The correct answer is E. The statement returns the employee name, salary, department ID, and maximum salary earned in. The statement returns the employee name, salary, department ID, and maximum salary earned in the department of the employee for all employees who earn less than the maximum salary in their department. This query is example of an inline view which is the sub-query in the FROM…

Displaying Data from Multiple Tables and Subqueries

Question

Evaluate the SQL statement: 1 SELECT a.emp_name, a.sal, a.dept_id, b.maxsal 2 FROM employees a, 3 (SELECT dept_id, MAX(sal) maxsal 4. FROM employees 5. GROUP BY dept_id) b 6. WHERE a.dept_id = b.dept_id 7. AND a.sal < b.maxsal; What is the result of the statement?

Options

  • AThe statement produces an error at line 1.
  • BThe statement produces an error at line 3.
  • CThe statement produces an error at line 6.
  • DThe statement returns the employee name, salary, department ID, and maximum salary earned in
  • EThe statement returns the employee name, salary, department ID, and maximum salary earned in

How the community answered

(38 responses)
  • A
    8% (3)
  • B
    13% (5)
  • C
    3% (1)
  • D
    3% (1)
  • E
    74% (28)

Explanation

The statement returns the employee name, salary, department ID, and maximum salary earned in the department of the employee for all employees who earn less than the maximum salary in their department. This query is example of an inline view which is the sub-query in the FROM clause of the main query. The sub-query can be a SELECT statement that utilizes joins, the GROUP BY clause, or the ORDER BY clause. Incorrect Answers A: The statement does not produce an error at line 1. B: The statement does not produce an error at line 3. C: The statement does not produce an error at line 6. D: The statement returns the employee name, salary, department ID, and maximum salary earned in the department of the employee for all EMPLOYEES, NOT DEPARTMENTS, who earn less than the maximum salary in their department.

Topics

#inline view#subquery in FROM clause#department max salary#self-join pattern

Community Discussion

No community discussion yet for this question.

Full 1Z0-007 Practice