🤔 문제 분석
1) Write an SQL query to report the name and balance of users with a balance higher than 10000. The balance of an account is equal to the sum of the amounts of all transactions involving that account.
💡 풀이
SELECT name, balance
FROM (SELECT T.account, U.name, SUM(amount) AS balance
FROM Transactions AS T
JOIN Users AS U ON T.account = U.account
GROUP BY T.account, U.name) AS sub
WHERE balance > 10000
'코딩테스트 > 리트코드 SQL' 카테고리의 다른 글
[리트코드/SQL] 33. Sales Analysis III (1084) (0) | 2023.02.14 |
---|---|
[리트코드/SQL] 31. Actors and Directors Who Cooperated At Least Three Times (1050) (0) | 2023.02.14 |
[리트코드/SQL] 30. Duplicate Emalis (182) (0) | 2022.12.23 |
[리트코드/SQL] 28. Top Travellers (1407) (0) | 2022.12.23 |
[리트코드/SQL] 27. Capital Gain/Loss(1393) (0) | 2022.12.21 |
댓글