LeetCode Medium 1193 Interview SQL Question with Detailed Explanation

preview_player
Показать описание

In this video I solve and explain a medium difficulty 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 includes points to keep in mind to develop SQL queries.

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
Рекомендации по теме
Комментарии
Автор

This is the most underrated channel of you tube in linkedin also everyone is busy in praising Sumit mittal sir only, i will proudly say i have learnt SQL from this channel

gajendragada_dynamites
Автор

in your video u have taught us how to think and how to solve the problem !! best tutorial ever on Database management system !

alfabinomial
Автор

here somehow if we use month alias in group by, then too query works fine!!, but generally group by runs before select so alias shouldn't be working but here it does??!! :select DATE_FORMAT(trans_date, "%Y-%m") as month, country, count(*) as trans_count,
sum(case when state='approved' then 1 else 0 end) as approved_count, sum(amount) as trans_total_amount,
sum(case when state='approved' then amount else 0 end) as approved_total_amount
from transactions
group by month, country;

mickyman
Автор

why does my code show this error? You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') as approved_total_amount
from Transactions
group by date_format(trans_date, '' at line 2

select date_format(trans_date, '%Y-%m') as month, country, count(id) as trans_count, sum (case when state='approved' then 1 else 0 end) as approved_count, sum(amount) as trans_total_amount, sum(case when state='approved' then anount else 0) as approved_total_amount
from Transactions
group by date_format(trans_date, '%Y-%m'), country

rishikaverma
Автор

count() only count the non-null values only.just for info

manojyadav
welcome to shbcf.ru