Max Quantity
Start Timer
0:00:00
Given the transactions
table, write a query to get the max quantity purchased for each distinct product_id
, every year.
The output should include the year
, product_id
, and max_quantity
for that product sorted by year and product_id
ascending.
Example:
Input:
transactions
table
Column | Type |
---|---|
id |
INTEGER |
user_id |
INTEGER |
created_at |
DATETIME |
product_id |
INTEGER |
quantity |
INTEGER |
Output:
Column | Type |
---|---|
year |
INTEGER |
product_id |
INTEGER |
max_quantity |
INTEGER |
Recommended questions for you
Personalized based on your user activity, skill level, and preferences.
.
.
.
.
.
.
.
.
.
Comments