OCP 1Z0 051 139

139. Which three statements are true about multiple-row subqueries? (Choose three.) 
A. They can contain a subquery within a subquery. 
B. They can return multiple columns as well as rows. 
C. They cannot contain a subquery within a subquery. 
D. They can return only one column but multiple rows. 
E. They can contain group functions and   GROUP BY and HAVING clauses. 
F. They can contain group functions and the GROUP BY clause, but not the HAVING clause. 


A C

SQL> SELECT e.*, d.dname
  2    FROM (SELECT e.deptno, SUM(e.sal) AS s_sal, SUM(e.sal * eb.st) AS s_bonus
  3            FROM emp e
  4           INNER JOIN (SELECT empno, SUM(TYPE / 10) AS st
  5                        FROM emp_bonus
  6                       GROUP BY empno) eb
  7              ON e.empno = eb.empno
  8           GROUP BY e.deptno) e
  9   INNER JOIN dept d
 10      ON d.deptno = e.deptno;
    DEPTNO      S_SAL    S_BONUS DNAME
---------- ---------- ---------- --------------
        10       8750       2135 ACCOUNTING
1 row selected

B D
SQL> SELECT e.deptno,eb.empno, e.sal, eb.st AS s_bonus
  2    FROM emp e
  3   INNER JOIN (SELECT empno, SUM(TYPE / 10) AS st
  4                 FROM emp_bonus
  5                GROUP BY empno) eb
  6      ON e.empno = eb.empno;
    DEPTNO  EMPNO        SAL    S_BONUS
---------- ------ ---------- ----------
        10   7782       2450        0.1
        10   7839       5000        0.3
        10   7934       1300        0.3
3 rows selected

E F
SQL> SELECT e.deptno, eb.empno, e.sal, eb.st AS s_bonus
  2    FROM emp e
  3   INNER JOIN (SELECT empno, SUM(TYPE / 10) AS st
  4                 FROM emp_bonus
  5                GROUP BY empno
  6               HAVING COUNT(*) > 1) eb
  7      ON e.empno = eb.empno;
    DEPTNO  EMPNO        SAL    S_BONUS
---------- ------ ---------- ----------
        10   7934       1300        0.3
1 row selected


Answer: ABE 

你可能感兴趣的:(OCP 1Z0 051 139)