Leetcode Problem 1587. Bank Account Summary II

1587. Bank Account Summary II

Leetcode Solutions

Calculate User Balances and Filter by Threshold

  1. Join the Users and Transactions tables on the account field.
  2. Group the results by the user's account to prepare for aggregation.
  3. Use the SUM function to calculate the total balance for each user.
  4. Use the HAVING clause to filter the results to only include users with a balance greater than 10000.
  5. Select the user's name and their calculated balance for the final output.
erDiagram
    Users {
        int account
        varchar name
    }
    Transactions {
        int trans_id
        int account
        int amount
        date transacted_on
    }
    Users ||--o{ Transactions : has

Aggregate Balances and Filter Using Subquery

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...