No video

Day 7: Solving Amazon SQL Interview Questions | 100 Days Challenge | CTE | Subquery | CTE

  Рет қаралды 1,077

Zero Analyst

Zero Analyst

Күн бұрын

Welcome to Day 7 of my 100 Days Challenge! Today, we're diving into Amazon SQL interview questions to help you ace your next tech interview.
Join me as I walk through each problem step-by-step, providing detailed explanations and practical tips. Don't forget to like, subscribe, and hit the bell icon to stay updated with daily challenges!
Join the 100 Days Challenge Community:
Discord: / discord
Get the question & datasets
GitHub: github.com/naj...
Relevant Playlists:
SQL Interview Prep: • SQL Challenge - Data A...
#AmazonInterview #SQLInterviewQuestions #100DaysChallenge #DataScience #SQLTutorial #TechInterviews #DataAnalysis #LearnSQL #InterviewPrep #CodingChallenge #TechCareer #SQLPractice #AmazonTech #DataEngineering #PythonInterview #ExcelTips"

Пікірлер: 13
@prashantkanhere8454
@prashantkanhere8454 Ай бұрын
Buddy, For question 1 it was so simple that SELECT COUNT(1) FROM ORDER WHERE CAST(ORDER_DATETIME AS DATE) = CAST ( ORDER_DATETIME as DATE ) -1
@zero_analyst
@zero_analyst Ай бұрын
yeah that's correct if we need total unit we have to do sum on qty column!
@harishsingh_424
@harishsingh_424 Ай бұрын
Thanks for bringing this series it's very helpful 👍
@vinothkumars7421
@vinothkumars7421 Ай бұрын
Just a quick clarification: Shouldn't we use Sum instead of Count for the units sold in Questions 1 and 2? Thanks. 93 Days to go
@rockstarreporter
@rockstarreporter Ай бұрын
Yes man I am also thinking the same way that u r thinking and most likely SUM will be used
@karanmthevar
@karanmthevar 25 күн бұрын
How can you compare a day. It will not work for all use cases. Suppose the data set has an order from 14th of the previous month then your comparison extra(day from current_date()) will bring in that data as well.
@nazimhussainmazumder4750
@nazimhussainmazumder4750 7 күн бұрын
SELECT COUNT(*) AS orders_yesterday FROM orders WHERE DATE(order_datetime) = CURRENT_DATE - INTERVAL '1 DAY';
@chharshith7000
@chharshith7000 Ай бұрын
4. Write a query to find the second earliest order_id for each customer for each date they placed 3 or more orders. Didn't this mean, query to fetch for each day a customer who has placed 3 or more orders???? no customer placed 3 orders a day.... In that case, the result set will be 0.
@gauraavthakurr
@gauraavthakurr Ай бұрын
Your first answer seems wrong, they asked how many units ordered yesterday which means total qty ordered yesterday. count won't work here instead use sum, also where clause is wrong (Postgresql 16.0) select total_units from ( select order_datetime::date as dates, sum(order_quantity) as total_units, row_number() over(order by order_datetime::date desc) rn from orders group by dates)t1 where rn = 2 or select sum(order_quantity) as total_unit_sold from orders where order_datetime::date = (select max(order_datetime::date) - interval '1 Day' from orders) incase anyone attacks me, ill clarify why its wrong. firstly , WHERE EXTRACT(DAY FROM order_datetime) = EXTRACT (DAY FROM CURRENT_DATE) - 1 t this line of filtering is wrong because its comparing day with day - 1, but table has same day in 2024, 2023. so its counting last years same day qty aswell, when we just want yesterdays qty sold. secondly, counting count is wrong because it will given count of rows and not total qty sold. so sum(order_quantity) is more appropriate. thirdly, everyone will get different answer if you use zero analyst code cause he usses current_date which gives real time date. so answer depends on day you run the query. both code I gave passes all test case, and will works almost in all situations. also, Mu code will give answer for yesday according to table data and not real time. because realtime where wouldn't work. If you want code which will work realtime then use this. select sum(order_quantity) as total_unit_sold from orders WHERE order_datetime::date = CURRENT_DATE - 1 (do not use extract here)
@zero_analyst
@zero_analyst Ай бұрын
Thanks for correcting! We should use sum on qty column!
@user-wi7mt5st2s
@user-wi7mt5st2s Ай бұрын
thank you ! nice explained
@user-wi7mt5st2s
@user-wi7mt5st2s Ай бұрын
please advise last written code does it works on Mysql .
@gauraavthakurr
@gauraavthakurr Ай бұрын
@@user-wi7mt5st2s for mysql you can use SELECT SUM(order_quantity) AS total_unit_sold FROM orders WHERE DATE(order_datetime) = CURDATE() - INTERVAL 1 DAY;
Day 6: Solving Zomato SQL Interview Questions | 100 Days Challenge
21:34
I Took a LUNCHBAR OFF A Poster 🤯 #shorts
00:17
Wian
Рет қаралды 6 МЛН
Чёрная ДЫРА 🕳️ | WICSUR #shorts
00:49
Бискас
Рет қаралды 6 МЛН
Parenting hacks and gadgets against mosquitoes 🦟👶
00:21
Let's GLOW!
Рет қаралды 13 МЛН
Data Scientist vs Data Analyst vs Data Engineer: What's the difference?
6:58