Member-only story

Repeat Purchases on Multiple Days – SQL Question Asked by Stich Fix

Solving question asked by Stitch Fix

Suraj Mishra
3 min readNov 17, 2022

Originally Published in https://asyncq.com/

Photo by Caspar Camille Rubin on Unsplash

Introduction

  • In this article we will solve Repeat Purchases on Multiple Days SQL question which is asked by Stitch Fix 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 purchases table which contains purchases made by different user on different days.
  • We have to output number of users who made purchase of same product on two or more days.

Solution

  • We will first partition our purchase table by user_id and product id, this partition will be order by date in ascending order. we will assign rank within each partition.

--

--

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