Interview questions
Predict the result, find the errors, explain the solution. You can read the questions without an account.
22 questions
Can you use a
SELECTalias inWHERE?Predict the resultJuniorWill
SUMtotal only three orders if you addLIMIT 3?Predict the resultJuniorWhat does
ORDER BYusing an alias return withLIMITandOFFSET?Predict the resultJuniorHow many rows does a window function see when the query includes
WHERE?Predict the resultMiddleCan you use an aggregate alias in
HAVING?Predict the resultMiddleCan you sort
SELECT DISTINCTby a column outside the select list?Predict the resultSeniorFind the bugs: employees earning above the company average
Find the errorsJuniorFind the bugs: the most recently hired employee in each department
Find the errorsMiddleFind the bugs: departments with at least two hires since 2021
Find the errorsMiddleWhich runs last:
SELECT,FROM,WHERE, orGROUP BY?ExplainJuniorFrom interview write-ups: T-BankDoes the database execute queries in logical order?
ExplainSeniorWhich statuses do
DISTINCTandLIMIT 2return?Predict the resultJuniorWhich groups remain after the
WHEREfilter?Predict the resultJuniorWhich departments remain after
LEFT JOINandWHERE?Predict the resultJuniorFind the bugs: paid orders report
Find the errorsMiddleWhat happens when
LIMITis inside a subquery?Predict the resultMiddleWill the ranking match the output order?
Predict the resultMiddleWhat happens when you combine
DISTINCTwith a windowCOUNT?Predict the resultMiddleWhat does
SELECT DISTINCT COUNT(*)return withGROUP BY?Predict the resultMiddleFind the bugs: the three highest-value paid orders
Find the errorsJuniorFind the bugs: total value of orders containing a specific product
Find the errorsMiddle