当前位置: 代码迷 >> Oracle认证考试 >> OCP 047的一路题
  详细解决方案

OCP 047的一路题

热度:477   发布时间:2016-04-24 03:51:11.0
OCP 047的一道题
49. View the Exhibit and examine the description of EMPLOYEES and DEPARTMENTS tables.
You want to display the EMPLOYEE_ID, LAST_NAME, and SALARY for the employees who get the
maximum salary in their respective departments. The following SQL statement was written:
WITH
SELECT employee_id, last_name, salary
FROM employees
WHERE (department_id, salary) = ANY (SELECT *
FROM dept_max)
dept_max as ( SELECT d.department_id, max(salary)
FROM departments d JOIN employees j
ON (d.department_id = j.department_id)
GROUP BY d.department_id)?
Which statement is true regarding the execution and the output of this statement?
A. The statement would execute and give the desired results.
B. The statement would not execute because the = ANY comparison operator is used instead of =.
C. The statement would not execute because the main query block uses the query name before it is even
created.
D. The statement would not execute because the comma is missing between the main query block and
the query name.
Answer: C
query name?具体哪个名字在创建前?

------解决方案--------------------
 query name 应该是dept_max,向下面那样写应该就对了

FROM ( SELECT d.department_id, max(salary)
       FROM departments d JOIN employees j
            ON (d.department_id = j.department_id)
       GROUP BY d.department_id) dept_max
  相关解决方案