Загрузка...

SQL Interview Question on DATEPART + SUBSTRING | Real-World Query | Day 3 #30DaySQLChallenge

Welcome to Day 3 of the #30DaySQLChallenge!
In this video, we tackle a real-world SQL interview question using a smart combination of DATEPART and SUBSTRING to filter dates based on weekday patterns. This technique is commonly used in data transformation and ETL pipelines — and is a favorite in SQL interviews!

🔍 What You'll Learn:
✅ How to use DATEPART(WEEKDAY, column)
✅ How to combine SUBSTRING with CASE WHEN
✅ Real-life logic to dynamically filter dates
✅ Best practices to write clean, readable SQL
Data:
create table Day_Indicator
(
Product_ID varchar(10),
Day_Indicator varchar(7),
Dates date
);
insert into Day_Indicator values ('AP755', '1010101', CONVERT(DATE,'04-Mar-2024', 102));
insert into Day_Indicator values ('AP755', '1010101', CONVERT(DATE,'05-Mar-2024', 102));
insert into Day_Indicator values ('AP755', '1010101', CONVERT(DATE,'06-Mar-2024', 102));
insert into Day_Indicator values ('AP755', '1010101', CONVERT(DATE,'07-Mar-2024', 102));
insert into Day_Indicator values ('AP755', '1010101', CONVERT(DATE,'08-Mar-2024', 102));
insert into Day_Indicator values ('AP755', '1010101', CONVERT(DATE,'09-Mar-2024', 102));
insert into Day_Indicator values ('AP755', '1010101', CONVERT(DATE,'10-Mar-2024', 102));
insert into Day_Indicator values ('XQ802', '1000110', CONVERT(DATE,'04-Mar-2024', 102));
insert into Day_Indicator values ('XQ802', '1000110', CONVERT(DATE,'05-Mar-2024', 102));
insert into Day_Indicator values ('XQ802', '1000110', CONVERT(DATE,'06-Mar-2024', 102));
insert into Day_Indicator values ('XQ802', '1000110', CONVERT(DATE,'07-Mar-2024', 102));
insert into Day_Indicator values ('XQ802', '1000110', CONVERT(DATE,'08-Mar-2024', 102));
insert into Day_Indicator values ('XQ802', '1000110', CONVERT(DATE,'09-Mar-2024', 102));
insert into Day_Indicator values ('XQ802', '1000110', CONVERT(DATE,'10-Mar-2024', 102));

Whether you're preparing for a data analyst, engineer, or BI interview — this SQL challenge is a must-practice!

📌 Challenge Yourself:
Try modifying the query to exclude weekends or only include alternate days. Share your solution in the comments!

🔔 Subscribe for the full #30DaySQLChallenge playlist!
👍 Like the video if this helped, and comment below with your questions or solutions.
Follow me on :
https://www.linkedin.com/in/shubhamsinghrao/
https://www.instagram.com/thetechtownttt
https://techtown.in/

Видео SQL Interview Question on DATEPART + SUBSTRING | Real-World Query | Day 3 #30DaySQLChallenge канала The Tech Town
Страницу в закладки Мои закладки
Все заметки Новая заметка Страницу в заметки

На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.

Об использовании CookiesПринять