This playlist contains scenario based SQL problems. After solving these you should be able to ace any SQL interview. As and when I find a good problem, i will add it to this playlist.
Curated by: Ankit Bansal (96 videos)
In this video we will solve a Blinkit Data Analyst SQL Assessment. This is one of the complex SQL question. You can expect these kind of SQL questions in startups and product based companies interviews. Practice more SQL and Spark questions here : https://www.namastesql.com/coding-problems Scripts: CREATE TABLE orders ( customer_id INT, order_date DATE, coupon_code VARCHAR(50) ); TRUNCATE TABLE Orders; -- ✅ Customer 1: First order in Jan, valid pattern INSERT INTO Orders VALUES (1, '2025-01-10', NULL); INSERT INTO Orders VALUES (1, '2025-02-05', NULL); INSERT INTO Orders VALUES (1, '2025-02-20', NULL); INSERT INTO Orders VALUES (1, '2025-03-01', NULL); INSERT INTO Orders VALUES (1, '2025-03-10', NULL); INSERT INTO Orders VALUES (1, '2025-03-15', 'DISC10'); -- last order with coupon ✅ -- ✅ Customer 2: First order in Feb, valid pattern INSERT INTO Orders VALUES (2, '2025-02-02', NULL); -- Month1 = 1 INSERT INTO Orders VALUES (2, '2025-02-05', NULL); -- Month1 = 1 INSERT INTO Orders VALUES (2, '2025-03-05', NULL); -- Month2 = 2 INSERT INTO Orders VALUES (2, '2025-03-18', NULL); INSERT INTO Orders VALUES (2, '2025-03-20', NULL); -- Month2 = 2 INSERT INTO Orders VALUES (2, '2025-03-22', NULL); INSERT INTO Orders VALUES (2, '2025-04-02', NULL); -- Month3 = 3 INSERT INTO Orders VALUES (2, '2025-04-10', NULL); INSERT INTO Orders VALUES (2, '2025-04-15', 'DISC20'); -- last order with coupon ✅ INSERT INTO Orders VALUES (2, '2025-04-16', NULL); -- Month3 = 3 INSERT INTO Orders VALUES (2, '2025-04-18', NULL); INSERT INTO Orders VALUES (2, '2025-04-20', 'DISC20'); -- last order with coupon ✅ -- ❌ Customer 3: First order in March but wrong multiples INSERT INTO Orders VALUES (3, '2025-03-05', NULL); -- Month1 = 1 INSERT INTO Orders VALUES (3, '2025-04-10', NULL); -- Month2 should have 2, but only 1 ❌ INSERT INTO Orders VALUES (3, '2025-05-15', 'DISC30'); -- ❌ Customer 4: First order in Feb but missing March (gap) INSERT INTO Orders VALUES (4, '2025-02-01', NULL); -- Month1 INSERT INTO Orders VALUES (4, '2025-04-05', 'DISC40'); -- Skipped March ❌ -- ❌ Customer 5: Valid multiples but last order has no coupon INSERT INTO Orders VALUES (5, '2025-01-03', NULL); -- M1 = 1 INSERT INTO Orders VALUES (5, '2025-02-05', NULL); -- M2 = 2 INSERT INTO Orders VALUES (5, '2025-02-15', NULL); INSERT INTO Orders VALUES (5, '2025-03-01', NULL); -- M3 = 3 INSERT INTO Orders VALUES (5, '2025-03-08', 'DISC50'); -- coupon mid INSERT INTO Orders VALUES (5, '2025-03-20', NULL); -- last order no coupon ❌ -- ❌ Customer 6: Skips month 2, should be excluded INSERT INTO Orders VALUES (6, '2025-01-05', NULL); -- Month1 = 1 order -- (no orders in Feb, so Month2 is missing ❌) INSERT INTO Orders VALUES (6, '2025-03-02', NULL); -- Month3 = 1st order INSERT INTO Orders VALUES (6, '2025-03-15', NULL); -- Month3 = 2nd order -- Jump to May (Month5 relative to Jan) INSERT INTO Orders VALUES (6, '2025-05-05', NULL); INSERT INTO Orders VALUES (6, '2025-05-10', NULL); INSERT INTO Orders VALUES (6, '2025-05-25', 'DISC60'); -- Last order with coupon Zero to hero(Advance) SQL Aggregation: https://youtu.be/5Ighj_2PGV0 Most Asked Join Based Interview Question: https://youtu.be/xR87ctOgpAE Solving 4 Trick SQL problems: https://youtu.be/Ck1gQrlS5pQ Data Analyst Spotify Case Study: https://youtu.be/-YdAIMjHZrM Top 10 SQL interview Questions: https://youtu.be/Iv9qBz-cyVA Interview Question based on FULL OUTER JOIN: https://youtu.be/KQfWd6V3IB8 Playlist to master SQL : https://youtube.com/playlist?list=PLBTZqjSKn0IeKBQDjLmzisazhqQy4iGkb Rank, Dense_Rank and Row_Number: https://youtu.be/xMWEVFC4FOk #sql #dataanalytics