Problem Description –
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.
Return the result table in any order.
The query result format is in the following example.


Problem Link – Bank Account II
Difficulty Level – Easy
Solution –
SELECT
DISTINCT
name,
balance
FROM (
SELECT
u.name,
SUM(t.amount) OVER(PARTITION BY u.name) as balance
FROM Transactions as t JOIN Users as u
ON t.account = u.account
) x
WHERE balance > 10000