Aggregation Practice #38

Aggregation Practice #38

Medium Programming Interview DBMS 18 views
Explanation Complexity

Problem Statement

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.

Input / Output Format

Input Format
SQL tables are described in the question.
Output Format
Write the SQL query.

Example Solution (Public)

Programming Interview
SELECT store_id, AVG(amount) AS avg_amount
FROM Sales
GROUP BY store_id
HAVING COUNT(*) >= 5;

Official Solution Code

SELECT store_id, AVG(amount) AS avg_amount
FROM Sales
GROUP BY store_id
HAVING COUNT(*) >= 5;
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.