Solved !!! SQL Question on Data Lemur | Amazon - Average Review Ratings

Опубликовано: 17 Март 2025
на канале: ETL SQL
268
9

Free SQL Pattern Training: https://etlsql.kartra.com/page/sps-fr...

Do you understand SQL but still cannot write SQL queries correctly ?
Are you afraid to switch jobs because of the SQL interview rounds or have you failed SQL Interview earlier ?
If you are someone who understands SQL and need more confidence to solve SQL queries correctly, I would like to share my recent online course especially created for you.
Check for more details: https://etlsql.kartra.com/page/sql-pa...

In this video I have solved SQL Question - Titled "Average Review Ratings" on Data Lemur platform.
Data Lemur referral link for easy reference: https://bit.ly/3SuF3wf

Hope you like the way I am explaining my thought process.
Let me know if this is helping you to solve SQL queries more confidently and you wish me to share more such videos.

Question:
Given the reviews table, write a query to get the average stars for each product every month.

The output should include the month in numerical value, product id, and average star rating rounded to two decimal places. Sort the output based on month followed by the product id.

Solution:
#############################

select extract('Month' from submit_date) as mth,
product_id,
cast(avg(stars) as decimal(3,2)) as avg_stars
from reviews
group by 1,2
order by 1,2;

#############################