Member-only story

Average Review Ratings — SQL Question Asked By Amazon

Solving SQL Question Asked By Amazon

Suraj Mishra
3 min readOct 15, 2022

Originally Published in https://asyncq.com/

Photo by Caspar Camille Rubin on Unsplash

Introduction

  • In this article we will solve Average Review Ratings SQL question which is asked by Amazon as per DataLemur website.

If you don’t know DatLemur then please do visit , it’s one of the best website to practice SQL questions and improve your SQL skills.

Question

  • We have been given reviews table, and our job is get average rating for each product for every month.
  • As we can see in the output , each product along with month has avg_stars column.

Solution

  • At first , we need to group all the records by product_id and month, and then we can perform average operation on the stars for that product during that month.
  • We have been given submit_date as datetime column, so…

--

--

Suraj Mishra
Suraj Mishra

Written by Suraj Mishra

Staff Software Engineer @PayPal ( All opinions are my own and not of my employer )

No responses yet