Interview questions
Predict the result, find the errors, explain the solution. You can read the questions without an account.
Topic: GROUP BY / HAVINGReset all
27 questions
Will
GROUP BYinclude a department with no employees?Predict the resultJuniorDoes
MAX(name)return the name of the highest-paid employee?Predict the resultJuniorWill a query using
GROUP BYrun ifSELECTincludes an ungrouped column?Predict the resultJuniorWhat does
WHEREfilter, and what doesHAVINGfilter?Predict the resultMiddleWill a customer with no paid orders disappear if the condition is inside
SUM?Predict the resultMiddleCan you add up unique user counts across groups?
Predict the resultMiddleWhat proportion of paid orders does
SUM(…) / COUNT(*)calculate?Predict the resultMiddleCan you select a column outside
GROUP BYwhen grouping by the primary key?Predict the resultSeniorFind the bugs: paid orders and unique buyers by month
Find the errorsJuniorFind the bugs: order counts and totals by customer
Find the errorsJuniorFind the bugs: units ordered and average unit price
Find the errorsMiddleFind the bugs: calculating company-wide average salary from department averages
Find the errorsMiddleWhat's the difference between
WHEREandHAVING?ExplainJuniorFind the bugs: minimum paid order amount per customer
Find the errorsJuniorHow do you sum item quantities in groups defined by a condition?
Predict the resultJuniorHow does
GROUP BYaggregate orders with different statuses?Predict the resultJuniorWhat happens when you cap each order versus the group total?
Predict the resultMiddleHow many rows does
HAVINGreturn withoutGROUP BY?Predict the resultMiddleHow many groups and orders does the outer query count?
Predict the resultMiddleWhich customers pass the
HAVINGcheck on order amounts?Predict the resultJuniorFind the bugs: revenue from repeat customers
Find the errorsMiddleFind the bugs: departments with payroll above the threshold
Find the errorsMiddle