In which four clauses can a sub query be used? (Choose four.)
A.
in the INTO clause of an INSERT statement
B.
in the FROM clause of a SELECT statement
C.
in the GROUP BY clause of a SELECT statement
D.
in the WHERE clause of a SELECT statement
E.
in the SET clause of an UPDATE statement
F.
in the VALUES clause of an INSERT statement
Explanation:
A: a sub query is valid on the INTO clause of an ISERT Statement
B: a sub query can be used in the FROM clause of a SELECT statement
D: a sub query can be used in the WHERE clause of a SELECT statement,
E: a sub query can be used in the SET clauses of an UPDATE statement,
Incorrect answer:
Csub query cannot be used
F: is incorrect.
It has to be B,D,E and F.
select * from (select * from demo_states) sta;
select * from demo_customers where cust_state in (
select st from demo_states where state_name = ‘MASSACHUSETTS’);
update demo_customers set cust_state = (
select st from demo_states where state_name = ‘MASSACHUSETTS’)
where cust_state = ‘FL’;
insert into demo_states (st, state_name)
select * from demo_states where st = ‘AL’;