Member-only story

Purchasing Activity by Product Type — Amazon Asked SQL Question

Solving SQL Question asked by Amazon

Suraj Mishra
3 min readNov 2, 2022

Originally Published in https://asyncq.com/

Photo by Caspar Camille Rubin on Unsplash

Introduction

  • In this article we will solve Purchasing Activity by Product Type 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 purchasing activity table and we need to find out cumulative purchases of each product over time.
  • As we can see in the output printer total cum_purchased count is 20 for the first purchase , for second purchase its 20+18 = 38. So basically we need to add total quantity purchased until previous date.

Solution

  • We will partition our input table by product_type which will be based on…

--

--

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