Y-on-Y Growth Rate [Wayfair SQL Interview Question]

 DML Script:

DROP TABLE IF EXISTS user_transactions;


CREATE TABLE user_transactions

(

transaction_id INT,

product_id INT,

spend int,

transaction_date datetime

)


INSERT INTO user_transactions

VALUES

(1341,123424,1500,'12/31/2019'),

(1423,123424,1000,'12/31/2020'),

(1623,123424,1246,'12/31/2021'),

(1322,123424,2145,'12/31/2022'),

(1349,123425,1805,'12/31/2019'),

(1429,123425,1605,'12/31/2020'),

(1629,123425,1045,'12/31/2021'),

(1329,123425,2945,'12/31/2022')


select * from user_transactions



Detailed explanation: https://youtu.be/_l3YAOB4m5Q

Comments

Popular posts from this blog

50 Essential SQL Questions to Land Your Dream Job

How to find all the customers who placed orders on three consecutive days | SQL Scenario questions

ACCENTURE SQL INTERVIEW QUESTION | Change the ProductIDs