In this video, we'll solve an advanced SQL challenge: correcting a swapping error in Zomato's order database. Imagine each order's item has been mistakenly swapped with the next—our task is to use Common Table Expressions (CTEs) to realign the order IDs with the correct items. Follow along as we solve this problem step-by-step and ensure data integrity.
Script --
CREATE TABLE orders (
order_id INT PRIMARY KEY,
item VARCHAR(255) NOT NULL
);
INSERT INTO orders (order_id, item) VALUES
(1, 'Chow Mein'),
(2, 'Pizza'),
(3, 'Veg Nuggets'),
(4, 'Paneer Butter Masala'),
(5, 'Spring Rolls'),
(6, 'Veg Burger'),
(7, 'Paneer Tikka');
TIMESTAMP
00:00 Introduction
00:15 Problem Description and Solution Approach
04:16 Solution Implementation
#sql #dataanalysts #dataengineer #dataanalysis #interviewquestion