filmov
tv
Amazon SQL Interview Question | SQL Advanced | Window Functions in SQL

Показать описание
In this video, we will solve an advanced SQL problem asked in Amazon Interviews.
Given the details of the Amazon customer, specifically focusing on the 'product_spend' table, which contains information about customer purchases, the products they bought, and how much they spent.
You need to find the top two highest-selling products within each category based on total spending. This problem will require us to utilize powerful SQL window functions, which are crucial for solving complex analytical queries efficiently.
Script -
CREATE TABLE ProductSpend (
category VARCHAR(50),
product VARCHAR(100),
user_id INT,
spend DECIMAL(10, 2)
);
INSERT INTO ProductSpend (category, product, user_id, spend) VALUES
('appliance', 'refrigerator', 165, 26.00),
('appliance', 'refrigerator', 123, 3.00),
('appliance', 'washing machine', 123, 19.80),
('electronics', 'vacuum', 178, 5.00),
('electronics', 'wireless headset', 156, 7.00),
('electronics', 'vacuum', 145, 15.00),
('electronics', 'laptop', 114, 999.99),
('fashion', 'dress', 117, 49.99),
('groceries', 'milk', 243, 2.99),
('groceries', 'bread', 645, 1.99),
('home', 'furniture', 276, 599.99),
('home', 'decor', 456, 29.99);
TIMESTAMP -
00:00 Problem Description & Approach
04:45 Solution Implementation on MySQL Workbench
#sql #advancedsql #sqltutorial #sqltutorialforbeginners #sqltutorials #sqltips #coding #dataanalysts #dataanalysis #sqlfordatascience #interviewpreparation #sqlserver #sqlfordataengineer #sqlinterviewquestions #interviewquestionsforfreshers #learnsql #datascienceforbeginners #dataanalysis #microsoft #dataanalysis #amazon #sqlforbeginners
Given the details of the Amazon customer, specifically focusing on the 'product_spend' table, which contains information about customer purchases, the products they bought, and how much they spent.
You need to find the top two highest-selling products within each category based on total spending. This problem will require us to utilize powerful SQL window functions, which are crucial for solving complex analytical queries efficiently.
Script -
CREATE TABLE ProductSpend (
category VARCHAR(50),
product VARCHAR(100),
user_id INT,
spend DECIMAL(10, 2)
);
INSERT INTO ProductSpend (category, product, user_id, spend) VALUES
('appliance', 'refrigerator', 165, 26.00),
('appliance', 'refrigerator', 123, 3.00),
('appliance', 'washing machine', 123, 19.80),
('electronics', 'vacuum', 178, 5.00),
('electronics', 'wireless headset', 156, 7.00),
('electronics', 'vacuum', 145, 15.00),
('electronics', 'laptop', 114, 999.99),
('fashion', 'dress', 117, 49.99),
('groceries', 'milk', 243, 2.99),
('groceries', 'bread', 645, 1.99),
('home', 'furniture', 276, 599.99),
('home', 'decor', 456, 29.99);
TIMESTAMP -
00:00 Problem Description & Approach
04:45 Solution Implementation on MySQL Workbench
#sql #advancedsql #sqltutorial #sqltutorialforbeginners #sqltutorials #sqltips #coding #dataanalysts #dataanalysis #sqlfordatascience #interviewpreparation #sqlserver #sqlfordataengineer #sqlinterviewquestions #interviewquestionsforfreshers #learnsql #datascienceforbeginners #dataanalysis #microsoft #dataanalysis #amazon #sqlforbeginners
Комментарии