filmov
tv
SQL Interview Question | Pivot, Row Number & Aggregate Functions | TCS Real SQL Problem Explained!!

Показать описание
create table occupations (
Name VARCHAR(50),
Occupation VARCHAR(20)
);
insert into occupations (Name, Occupation) values
('Jenny', 'Doctor'),
('Samantha', 'Doctor'),
('Ashley', 'Professor'),
('Christeen', 'Professor'),
('Ketty', 'Professor'),
('Meera', 'Singer'),
('Priya', 'Singer'),
('Jane', 'Actor'),
('Julia', 'Actor'),
('Maria', 'Actor');
/*
We use ROW_NUMBER() to ensure that each name in the same occupation category gets a unique row index.
This helps us align names correctly when we pivot the data
max selects the highest non null value
*/
--------------------------------------------------------------------------------------------
🔍 Master SQL & Python with Me! 💡
Welcome to Data Dive Academy, your go-to hub for mastering SQL, Python, and complex queries! 🚀 Whether you're a beginner or an advanced data enthusiast, I’ll be sharing:
✅ SQL tricks & advanced queries 🗄️
✅ Python for data automation & analytics
✅ Step-by-step tutorials & quick tips ⏳
✅ Shorts & deep dives on real-world problems 🎯
Let’s optimize queries, automate tasks, and level up our data skills together! Follow for daily insights & practical coding content. 📊🔥 #SQL #Python #DataScience
Name VARCHAR(50),
Occupation VARCHAR(20)
);
insert into occupations (Name, Occupation) values
('Jenny', 'Doctor'),
('Samantha', 'Doctor'),
('Ashley', 'Professor'),
('Christeen', 'Professor'),
('Ketty', 'Professor'),
('Meera', 'Singer'),
('Priya', 'Singer'),
('Jane', 'Actor'),
('Julia', 'Actor'),
('Maria', 'Actor');
/*
We use ROW_NUMBER() to ensure that each name in the same occupation category gets a unique row index.
This helps us align names correctly when we pivot the data
max selects the highest non null value
*/
--------------------------------------------------------------------------------------------
🔍 Master SQL & Python with Me! 💡
Welcome to Data Dive Academy, your go-to hub for mastering SQL, Python, and complex queries! 🚀 Whether you're a beginner or an advanced data enthusiast, I’ll be sharing:
✅ SQL tricks & advanced queries 🗄️
✅ Python for data automation & analytics
✅ Step-by-step tutorials & quick tips ⏳
✅ Shorts & deep dives on real-world problems 🎯
Let’s optimize queries, automate tasks, and level up our data skills together! Follow for daily insights & practical coding content. 📊🔥 #SQL #Python #DataScience