Interview questions
Predict the result, find the errors, explain the solution. You can read the questions without an account.
23 questions
Which duplicates does
GROUP BY … HAVING COUNT(*) > 1find?Predict the resultJuniorWill
LIMIT 1 OFFSET 1return the second-highest salary?Predict the resultJuniorHow many rows will
DENSE_RANKreturn for the top 2 salaries in each department?Predict the resultMiddleWill an event without a user appear in the “latest event per user” results?
Predict the resultMiddleWhich order will
DISTINCT ONkeep for each customer?Predict the resultMiddleHow many rows does
FETCH FIRST 2 ROWS WITH TIESreturn?Predict the resultSeniorFind the bugs: Count distinct events per user
Find the errorsJuniorFind the bugs: Which rows remain after deduplication?
Find the errorsMiddleFind the bugs: Highest-paid employees in each department
Find the errorsMiddleFind the bugs: Second-highest salary in each department
Find the errorsSeniorHow do you find the second-highest salary?
ExplainJuniorWhich events will a query with
LIMITandOFFSETreturn?Predict the resultJuniorWhat remains after applying
UNION DISTINCTto two tables?Predict the resultJuniorFind the bugs: Deduplicating an event log
Find the errorsJuniorWhich row will
ROW_NUMBERkeep for each product?Predict the resultJuniorWhich rows will a query with
GROUP BYandLIMITreturn?Predict the resultMiddleWhich city and order status pairs will
DISTINCTkeep?Predict the resultJuniorWhat will a query using
DISTINCTandUNION ALLreturn?Predict the resultMiddleHow do you paginate when the sort key can change?
ExplainSeniorFind the bugs: Each customer's latest paid order
Find the errorsMiddleFind the bugs: Top two products by units sold
Find the errorsMiddleWhich rows pass the running total filter?
Predict the resultMiddle