Which three statements are true regarding sub queries? (Choose three.)
A. Multiple columns or expressions can be compared between the main query and sub query
B. Sub queries can contain GROUP BY and ORDER BY clauses
C. Only one column or expression can be compared between the main query and subqeury
D. Main query and sub query can get data from different tables
E. Main query and sub query must get data from the same tables
F. Sub queries can contain ORDER BY but not the GROUP BY clause
B is wrong sub query cant contain order by clause
Yes it can. It’s just rarely (if ever) needed because sorting should be done in the outermost query instead.
this query is not going to work
select * from orders where order_id in (select order_id from orders_direct order by order_id);
so I am not sure about ORDER BY in sub-query
You may try it in FROM CLAUSE
if SUB-QUERY is used in FROM clause it is called INLINE VIEW and not a SUB-QUERY
in that case expression like this will work of course
select * from orders o, (select order_id from orders_direct order by order_id) inline_view
where o.order_id = inline_view.order_id;
but it is not a SUB-QUERYm it is INLINE VIEW,
so B is wrong