feedback has one row per product review (product_id, stars). Reviews with a NULL star value were not rated and must be ignored. For each product with at least one rating, compute the average star rating. Output columns: product_id, avg_stars (rounded to 2 decimals). Order by product_id ascending.
| Column | Type |
|---|---|
| product_id | INTEGER |
| stars | REAL |
| product_id | stars |
|---|---|
| 1 | 5 |
| 1 | 4 |
| 1 | 3 |
| 2 | 5 |
| 2 | 5 |
| 3 | 2 |
| product_id | avg_stars |
|---|---|
| 1 | 4 |
| 2 | 5 |
| 3 | 2 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Cities With Settled Orders · Employees Above Supervisor Pay ›
{{ totalCount }} questions in the style asked at Amazon, Microsoft, Google, Meta, Flipkart and more — {{ hardPct }}% Hard. Write SQL in a real database engine in your browser, run it on sample data, then evaluate against hidden tests.
Company tags show where this type of question is commonly reported in interviews. Questions, data and solutions are written by TechTown.
{{ cur.statement }}
No submissions yet. Press Evaluate to submit your query.
{{ solutionSql }}
{{ out.error }}
You have solved your 3 free questions — nice work! Log in (free) to unlock all 150 questions, keep your streak and appear on the leaderboard.