Interview questions
Predict the result, find the errors, explain the solution. You can read the questions without an account.
Topic: Subqueries, CTEs, EXISTS / IN, UNIONReset all
25 questions
How many departments does this
EXISTSquery return?Predict the resultJuniorCan a subquery in
FROMrun without an alias?Predict the resultMiddleWhich orders does
EXISTSfind when checking for a later order?Predict the resultMiddleHow many customers does
INfind when the subquery returnsNULL?Predict the resultMiddleHow many rows does
UNION ALLreturn withLIMIT 3at the end?Predict the resultMiddleHow many rows will
INTERSECTreturn for paid orders and customers fromBerlin?Predict the resultMiddleHow many employees from
Saleswill this query find?Predict the resultSeniorFind the bugs: orders from Berlin customers
Find the errorsJuniorFind the bugs: the highest-priced item in each order
Find the errorsMiddleFind the bugs: employee reporting hierarchy
Find the errorsMiddleWhat's the difference between
UNIONandUNION ALL?ExplainJuniorWhat is a correlated subquery?
ExplainJuniorHow does
INwith a subquery differ fromEXISTS?ExplainMiddleWho earns more than the highest-paid employee in
Sales?Predict the resultJuniorWhat does a subquery in the
SELECTlist return?Predict the resultJuniorWhich orders have totals above the average for paid orders?
Predict the resultMiddleWhich values does the nested query with
EXCEPTreturn?Predict the resultJuniorWhich customers pass the aggregate filter?
Predict the resultMiddleWhich customers have only paid orders?
Predict the resultMiddleWhich department will the nested
MAXselect?Predict the resultMiddleFind the bugs: orders with at least two line items
Find the errorsJuniorFind the bugs: customers with multiple paid orders
Find the errorsMiddleFind the bugs: three required event types
Find the errorsMiddleWhen can you push a filter into a subquery?
ExplainSenior