LeetCode 1587 Interview SQL Question with Detailed Explanation | Practice SQL

preview_player
Показать описание
Previous Video: LeetCode 1581 Customers Visited but No Transactions

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 bank account summary and customers per month and also 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
Рекомендации по теме
Комментарии
Автор

with cte as(
select u.name, (select sum(t.amount) from transactions t group by t.account having t.account=u.account)
as balance from users u
)

select * from cte where balance > 10000;

I have learnt to use cte from your videos and now i able to apply my logic.

aaravkumarsingh
Автор

I have solved the same problem like this

WITH cte AS
(SELECT account, SUM(amount) AS balance
FROM Transactions
GROUP BY account),

cte2 AS
(SELECT *
FROM cte
WHERE balance > 10000)

SELECT name, balance
FROM cte2 LEFT JOIN Users
USING (account)

The code is big, but isn't it better to break down big table into small and then join them. We can have faster query execution like that

parikshitgupta
Автор

I feel that group by should be done using account and not name as account is a primary key and name can be duplicated.

madhuryadav