No video

SQL Interview Question - Solution (Part - V) | Data Analyst | Data Engineers

  Рет қаралды 668

MeanLifeStudies

MeanLifeStudies

Күн бұрын

In this video, we solved two problems as part of the SQL interview preparation series for data analyst or data engineer interviews.
#sql #dataengineers #dataanalyst #interview #datascience #sqlinterveiw
#sqlfunctions
Here are the create and insert statements for the given data:
-------------------------------------------------------------------------------------------
create table bookings(
Booking_id varchar(5)
,Booking_date date
,userid varchar(5)
,Line_of_business varchar(10)
);
insert into bookings values ('b1','2022-05-23','u1','Flight'),
('b2','2022-05-27','u2','Flight'),('b3','2022-03-28','u1','Hotel'),
('b4','2022-02-11','u4','Flight'),('b5','2022-04-02','u1','Hotel'),('b6','2022-04-02','u2','Flight'),
('b7','2022-01-26','u5','Flight'),('b8','2022-03-06','u6','Hotel'),('b9','2022-05-06','u2','Flight'),
('b10','2022-07-10','u1','Flight'),('b11','2022-04-12','u4','Flight'),('b12','2022-05-16','u1','Flight'),
('b13','2022-08-19','u2','Flight'),('b14','2022-04-20','u5','Hotel'),('b15','2022-08-22','u6','Flight'),
('b16','2022-02-26','u4','Hotel'),('b17','2022-03-28','u2','Hotel'),('b18','2022-07-30','u1','Hotel');
('b19','2022-04-04','u4','Hotel'),
('b20','2022-05-06','u1','Flight');
create table users(userid varchar(5) ,Slot varchar(5))
insert into users values ('u1','s1'),('u2','s1'), ('u3','s1'),('u4','s2'),
('u5','s2'),('u6','s3'), ('u7','s3'),('u8','s3'),('u9','s3'), ('u10','s3');

Пікірлер: 2
@VARUNTEJA73
@VARUNTEJA73 2 ай бұрын
with cte as( select *,row_number()over(partition by userid order by booking_date)ranks from bookings) select userid from cte where ranks=1 and line_of_business like'%flight%'
@king-hc6vi
@king-hc6vi 2 ай бұрын
My approach will be to use row number by partitioning it on basis of user I'd and order by date. And then use case statement where flight =1 and rest =0. Keep this whole thing in CTE. Then filter out the result Select user ID from CTE Where row number =1 and Case statement result = 1 ( where 1 denotes flight mode).. Kindly let me know if this approach is correct or not.. Many thanks ❤
OMG what happened??😳 filaretiki family✨ #social
01:00
Filaretiki
Рет қаралды 13 МЛН
Zombie Boy Saved My Life 💚
00:29
Alan Chikin Chow
Рет қаралды 28 МЛН
What will he say ? 😱 #smarthome #cleaning #homecleaning #gadgets
01:00
I learned SQL for data analytics in 15 days | From Scratch
4:10
Techie Saumya
Рет қаралды 493 М.
Learn SQL + Database Concepts in 20 Minutes
24:34
Chandoo
Рет қаралды 51 М.
The 25 SQL Questions You MUST Know for Data Analyst Interviews
32:47
KSR Datavizon
Рет қаралды 215 М.
OMG what happened??😳 filaretiki family✨ #social
01:00
Filaretiki
Рет қаралды 13 МЛН