50、(11-15)choose two
Examine the structure of the MARKS table:
Which two statements would execute successfully?
A) SELECT SUM(subjectl+subject2+subject3)
FROM marks
WHERE student_name IS NULL;
B) SELECT SUM(DISTINCT NVL(subject1,0)), MAX(subjectl)
FROM marks
WHERE subjectl > subject2;
C) SELECT student_name,subjectl
FROM marks
WHERE subjectl > AVG(subjectl);
D) SELECT student_name, SUM (subjectl)
FROM marks
WHERE student_name LIKE 'R%';
Answer:AB
(解析:C 答案 where 子句中用到了 avg 函数,必须用 having;D 答案 student_name 没有在 group by 子句中出现。
B 答案可以写成如下方式运行:
SELECT SUM(DISTINCT NVL(comm,0)), MAX(sal)
FROM emp
WHERE sal > comm;
)