Aggregation Practice #11
Programming Interview
Medium
4 views
Problem Description
Table: Sales(store_id, amount). Return store_id and average amount, only stores with at least 5 rows.
Input Format
SQL tables are described in the question.
Output Format
Write the SQL query.
Official Solution
SELECT store_id, AVG(amount) AS avg_amount
FROM Sales
GROUP BY store_id
HAVING COUNT(*) >= 5;
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!