OCP 1Z0 051 QUESTION NO: 40

来源:互联网 发布:陌陌加人软件 编辑:程序博客网 时间:2024/06/16 08:15
QUESTION NO: 40 
 
Which two are true about aggregate functions? (Choose two.)

 
A. You can use aggregate functions in any clause of a SELECT statement. 
B. You can use aggregate functions only in the column list of the select clause and in the WHERE
clause of a SELECT statement. 
C. You can mix single row columns with aggregate functions in the column list of a SELECT
statement by grouping on the single row columns. 
D. You can pass column names, expressions, constants, or functions as parameter to an
aggregate function. 
E. You can use aggregate functions on a table, only by grouping the whole table as one single
group. 
F. You cannot group the rows of a table by more than one column while using aggregate
functions. 

A B
select、having与order by子句中可以用聚合函数
SQL> SELECT deptno, SUM(sal) AS s_sal  2    FROM emp  3   GROUP BY deptno  4  HAVING SUM(sal) > 9000  5   ORDER BY COUNT(*);    DEPTNO      S_SAL---------- ----------        20      10875        30       94002 rows selected

where 子句中不能使用聚合函数
SQL> SELECT deptno, SUM(sal) AS s_sal  2    FROM emp  3   WHERE SUM(sal) > 9000  4   GROUP BY deptno;SELECT deptno, SUM(sal) AS s_sal  FROM emp WHERE SUM(sal) > 9000 GROUP BY deptnoORA-00934: group function is not allowed here

C 见前面举例

D
SQL> SELECT deptno,  2         SUM(sal) AS colname,  3         SUM(sin(sal)) AS fun,  4         SUM(1) AS cons,  5         SUM(sal + 10) AS exp  6    FROM emp  7   GROUP BY deptno;    DEPTNO    COLNAME        FUN       CONS        EXP---------- ---------- ---------- ---------- ----------        30       9400 -2.0869580          6       9460        20      10875 1.84874246          5      10925        10       8750 -1.9964714          3       87803 rows selected

E 见前面举例
F
SQL> SELECT deptno, SUM(sal) AS sal, SUM(comm) AS comm FROM emp GROUP BY deptno;    DEPTNO        SAL       COMM---------- ---------- ----------        30       9400       2200        20      10875         10       8750 3 rows selected


答案错误,A不对
 

Answer: A,D
0 0
原创粉丝点击