LeetCode 1280 Interview SQL Question with Detailed Explanation | Practice SQL

  Рет қаралды 11,540

Everyday Data Science

Everyday Data Science

2 жыл бұрын

Previous Video: LeetCode 1294 Employee Team Size
• LeetCode 1303 Intervie...
In this video I solve and explain a leetcode SQL question using MySQL query. This question has been asked in Apple, Facebook, Amazon, Google, Adobe, Microsoft, Adobe interviews or what we popularly call FAANG interviews.
I explain the related concept as well. This question is about students and examinations and also includes points to keep in mind to develop SQL queries. You will also learn about COMMON TABLE EXPRESSIONS.
LeetCode is the best platform to help you enhance your skills, expand your knowledge and prepare for technical interviews.
If you found this helpful, Like and Subscribe to the channel for more content.
#LeetCodeSQL #FAANG #SQLinterviewQuestions

Пікірлер: 43
@rb4754
@rb4754 11 ай бұрын
I was pleasantly surprised to find such valuable content on this channel, even though it currently has only 3.2k subscribers. The way the problem was explained step by step was truly exceptional, and I have watched many videos on this topic before, but none of them were as clear and thorough as yours. Your ability to pass on knowledge efficiently is commendable, and I truly appreciate the effort you put into making such educational videos. I strongly encourage you to continue producing content with the same patience and dedication. I have no doubt that if you keep creating videos of this quality, your channel will grow rapidly and attract a much larger audience. Not everyone possesses the skill to teach complex concepts effectively, but you certainly have a talent for it.Your hard work and commitment to providing valuable educational resources deserve recognition, and I believe you will achieve great success in the future. Keep up the excellent work, and thank you so much for sharing your knowledge.
@Mech2ML
@Mech2ML 10 ай бұрын
seriously this is a real quality content thanks a lot for helping
@ambeshpandey8937
@ambeshpandey8937 27 күн бұрын
one thing i can say best way anyone has explained
@EverydayDataScience
@EverydayDataScience 26 күн бұрын
Thanks for such kind words 😊 Glad that you found the video useful.
@ashishgupta-bw8pt
@ashishgupta-bw8pt 10 ай бұрын
great videos. keep it up. bro.
@sinchanagowda8302
@sinchanagowda8302 2 ай бұрын
Very clear and insightful, Thanks for the video!
@EverydayDataScience
@EverydayDataScience 2 ай бұрын
Glad that you found the video useful 😊
@helenwu4563
@helenwu4563 2 жыл бұрын
very clear and easy to understand, thank you so much for doing this video. I thought this one is a hard one though it is categorized in easy😂 your logic makes sense to me
@EverydayDataScience
@EverydayDataScience 2 жыл бұрын
Glad you found it helpful, Helen.
@professorpoke
@professorpoke Ай бұрын
It indeed is hard. Definitely not an easy one.
@abhisheksinghyadav4970
@abhisheksinghyadav4970 5 ай бұрын
Thanks man I dont usually comment on videos. but this solution is beautifully explained as well as others. Keep posting you'll grow alot for sure.
@alfabinomial6183
@alfabinomial6183 Жыл бұрын
YOU ARE AWESOMEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!!!!!!!!!
@fighterdse3589
@fighterdse3589 11 ай бұрын
Very clear!!!🥳🥳
@taylorkaser7529
@taylorkaser7529 2 ай бұрын
thank you this was great :)
@VishnuvardhanJadava
@VishnuvardhanJadava Ай бұрын
great video. I think we can simply use ifnull instead of case.
@aaravkumarsingh4018
@aaravkumarsingh4018 2 жыл бұрын
explained in very easy and detail way
@EverydayDataScience
@EverydayDataScience 2 жыл бұрын
Glad that you found it useful, Aarav.
@clouddrive6833
@clouddrive6833 Жыл бұрын
That's Great Here is an alternate way : # Write your MySQL query statement below WITH cte1 AS ( SELECT * FROM students CROSS JOIN subjects ), cte2 AS ( SELECT student_id, subject_name, COUNT(subject_name) AS val FROM examinations GROUP BY student_id, subject_name ) SELECT cte1.*, COALESCE(cte2.val, 0) AS attended_exams FROM cte1 LEFT JOIN cte2 ON cte1.student_id = cte2.student_id AND cte1.subject_name = cte2.subject_name order by student_id,subject_name;
@kavyabanka4482
@kavyabanka4482 Жыл бұрын
WOW THIS IS FABULOUS EXPLANATION
@irislynn4970
@irislynn4970 2 жыл бұрын
thank you , appreciate this
@EverydayDataScience
@EverydayDataScience 2 жыл бұрын
Glad you liked it, Iris.
@sauravchandra10
@sauravchandra10 Ай бұрын
Good question in terms of the variety of information. How can we do a cross join in pandas?
@user-yd1fu7hl6j
@user-yd1fu7hl6j 10 ай бұрын
Amazing Explination
@EverydayDataScience
@EverydayDataScience 10 ай бұрын
Glad that you found the video useful 😊
@continnum_radhe-radhe
@continnum_radhe-radhe 9 ай бұрын
❤❤❤
@EverydayDataScience
@EverydayDataScience 9 ай бұрын
Glad that you found the video useful 😊
@neelshah8247
@neelshah8247 Жыл бұрын
If you're using SQL Server, you can use the ISNULL() Function instead of the CASE Statements.
@saisushanthdurvasulabitsian
@saisushanthdurvasulabitsian Жыл бұрын
as usual excellent explanation , thank you , here is alternate way with one cte less, pls review and let me know: with cte(student_id,student_name,subject_name) as ( select stu.student_id , stu.student_name , sub.subject_name from students stu, subjects sub ) select c.student_id , c.student_name , c.subject_name , sum(case when (ex.student_id is null or ex.subject_name is null) then 0 else 1 end) as attended_exams from cte c left outer join examinations ex on (c.student_id = ex.student_id and c.subject_name = ex.subject_name) group by c.student_id,c.subject_name order by c.student_id,c.subject_name
@aniketyadav343
@aniketyadav343 11 ай бұрын
One of the longest query for sure
@mlvprasadofficial
@mlvprasadofficial 2 жыл бұрын
23
@patiladiti2116
@patiladiti2116 3 ай бұрын
Solution w/o common table: SELECT s.student_id, s.student_name, sub.subject_name, COUNT(e.subject_name) as attended_exams FROM Students AS s CROSS JOIN Subjects AS sub LEFT JOIN Examinations AS e ON s.student_id = e.student_id AND sub.subject_name = e.subject_name GROUP BY s.student_id, sub.subject_name ORDER BY s.student_id, sub.subject_name;
@containthis4450
@containthis4450 Жыл бұрын
this is suppose to be an easy question.. I think there should be an easier solution because you lost me in the first 3 minutes
@containthis4450
@containthis4450 Жыл бұрын
select a.student_id, a.student_name, b.subject_name, count(c.subject_name) as attended_exams from Students as a join Subjects as b left join Examinations as c on a.student_id = c.student_id and b.subject_name = c.subject_name group by a.student_id, b.subject_name ORDER BY a.student_id, b.subject_name;
@EverydayDataScience
@EverydayDataScience 11 ай бұрын
Definitely, there can be many easier solutions to this. I’ll try to keep this mind going forward , thanks for pointing it out 😊
@shashankshekhar8186
@shashankshekhar8186 11 ай бұрын
Glad someone spoked
@rb4754
@rb4754 11 ай бұрын
@@EverydayDataScience No you did right thing. There could be more simpleistic ways. However, with this one explaination I understood many concepts such as case, cross join, CTE. That is an awesome explanation. Keep up this. Thank you.
@ashmitachakraborty6637
@ashmitachakraborty6637 4 ай бұрын
Hey, thank you for the video. However, when I tried, only two test cases passed out of 14. Following is the code I did, With cte1 as ( Select * from Students Cross join Subjects ), /* 1 Alice Math 1 Alice Physics*/ cte2 as ( Select student_id, subject_name, count(subject_name) as count From Examinations Group by student_id, subject_name ) /* 1 Math 3 1 Physics 2 */ Select cte1.student_id, cte1.student_name, cte1.subject_name, case when count is not null then count else 0 end as attended_exams From cte1 LEFT JOIN cte2 ON cte1.student_id = cte2.student_id #1 Alice Math and cte1.subject_name and cte2.subject_name #1 Alice Math 3 ORDER By cte1.student_id, cte1.subject_name Could you kindly point me in the right direction for this? The count function is not working right for me at all. It's coming as zero. Any help is appreciated.
@EverydayDataScience
@EverydayDataScience 4 ай бұрын
Try renaming count(subject_name) to something else, not count and then use it.
@ashmitachakraborty6637
@ashmitachakraborty6637 4 ай бұрын
@@EverydayDataScience still the same
@ashmitachakraborty6637
@ashmitachakraborty6637 4 ай бұрын
I had put an 'and' in place of =. Thanks for responding.
@ashishsuman7079
@ashishsuman7079 8 ай бұрын
A bit more time taking but easier approach ..for beginners. SELECT Students.student_id, Students.student_name, Subjects.subject_name, COUNT(Examinations.subject_name) AS attended_exams FROM Students CROSS JOIN Subjects LEFT JOIN Examinations ON Students.student_id = Examinations.student_id AND Subjects.subject_name = Examinations.subject_name GROUP BY student_name, subject_name ORDER BY student_id, subject_name
@firzainsanudzaky3763
@firzainsanudzaky3763 8 ай бұрын
do you think if i was an intern should i use edds method or your method ?
@antonigolos1406
@antonigolos1406 3 ай бұрын
@@firzainsanudzaky3763 I am pretty sure that this method was the intendent one. I would rather avoid using cte if you do not need to
LeetCode 1350 Interview SQL Question with Detailed Explanation | Practice SQL
5:27
Can You Draw A PERFECTLY Dotted Line?
00:55
Stokes Twins
Рет қаралды 111 МЛН
КАК ДУМАЕТЕ КТО ВЫЙГРАЕТ😂
00:29
МЯТНАЯ ФАНТА
Рет қаралды 1,2 МЛН
Nutella bro sis family Challenge 😋
00:31
Mr. Clabik
Рет қаралды 13 МЛН
I CAN’T BELIEVE I LOST 😱
00:46
Topper Guild
Рет қаралды 115 МЛН
LeetCode 1280: Students and Examinations - Interview Prep Ep 23
12:36
LeetCode 1421 Interview SQL Question with Detailed Explanation | Practice SQL
7:30
LeetCode Medium 1164 Amazon Interview SQL Question with Detailed Explanation
9:50
LeetCode Medium 1193 Interview SQL Question with Detailed Explanation
9:00
Everyday Data Science
Рет қаралды 3,8 М.
1280. Students and Examinations| Leetcode SQL Easy
7:02
Tech Timeout
Рет қаралды 2,8 М.
Can You Draw A PERFECTLY Dotted Line?
00:55
Stokes Twins
Рет қаралды 111 МЛН