一、原题
二、题目翻译
三、题目解析
D选项测试如下:
SQL> select deptno,sum(sal)
2 from emp
3 group by (select deptno from dept);
group by (select deptno from dept)
*
ERROR at line 3:
ORA-22818: subquery expressions not allowed here
Where can subqueries be used? (Choose all that apply.)
A. field names in the SELECT statement.
B. the FROM clause in the SELECT statement.
C. the HAVING clause in the SELECT statement.
D. the GROUP BY clause in the SELECT statement.
E. the WHERE clause in only the SELECT statement.
F. the WHERE clause in SELECT as well as all DML statements.
答案:ABCF
A. field names in the SELECT statement.
B. the FROM clause in the SELECT statement.
C. the HAVING clause in the SELECT statement.
D. the GROUP BY clause in the SELECT statement.
E. the WHERE clause in only the SELECT statement.
F. the WHERE clause in SELECT as well as all DML statements.
答案:ABCF
二、题目翻译
子查询可以在哪里被使用?(选择所有正确的选项)
A.SELECT语句中的字段名称。
B.SELECT语句的FROM子句中。
C.SELECT语句的HAVING子句中。
D.SELECT语句的GROUP BY子句中。
E.只能用于WHERE子句。
F.SELECT与DML语句的WHERE子句中。
A.SELECT语句中的字段名称。
B.SELECT语句的FROM子句中。
C.SELECT语句的HAVING子句中。
D.SELECT语句的GROUP BY子句中。
E.只能用于WHERE子句。
F.SELECT与DML语句的WHERE子句中。
三、题目解析
A选项正确,标量子查询就是的。
B、C、F选项都正确,子查询可用于FROM、HAVING、WHERE等子句中,并且SELECT也可以使用在UPDATE、DELETE、INSERT等DML语句中。
对应的,D、E选项就不正确了。
四、测试B、C、F选项都正确,子查询可用于FROM、HAVING、WHERE等子句中,并且SELECT也可以使用在UPDATE、DELETE、INSERT等DML语句中。
对应的,D、E选项就不正确了。
D选项测试如下:
SQL> select deptno,sum(sal)
2 from emp
3 group by (select deptno from dept);
group by (select deptno from dept)
*
ERROR at line 3:
ORA-22818: subquery expressions not allowed here