AnalystPath

Units Dispensed per Drink

SQLEasyJunior level~15 min

Problem

Table: `dispense_log`

| Column Name | Type |
|---|---|
| log_id | int |
| drink_id | int |
| machine_id | int |
| units | int |

`log_id` is the primary key. Each row records how many `units` of a drink were dispensed in one transaction.

Report the total number of units dispensed for every `drink_id` under the alias `total_units`. Return the result in any order.

Tables

Example rows — the live problem includes the full dataset.

dispense_log
log_iddrink_idmachine_idunits
1100910
2100412
7200415

Expected output

Your answer should return 2 rows with the columns drink_id, total_units.

Starter code (SQL)

SELECT *
FROM dispense_log;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions