My scenario is as follows -
I have these records in my DB table (Table name: MyTable):
ID ACCOUNT_NUM DATE BALANCE
------------------------------------ ----------- ---------- -----------
111 1 2020-12-17 500000.0000
111 2 2020-12-17 500000.0000
222 1 2020-12-17 500000.0000
222 2 2020-12-17 400000.0000
333 1 2020-12-17 800000.0000
333 2 2020-12-17 300000.0000
444 1 2020-12-17 1000000.0000
444 2 2020-12-17 100.0000
Each ID represents a member and each member has 2 accounts.
I need to return only the records which have an aggregated balance of over 1000000.00 (1M) by adding account 1 and 2 for each ID.
Ive tried this so far:
SELECT ID, ACCOUNT_NUM, DATE, BALANCE FROM MyTable
GROUP BY ID, ACCOUNT_NUM, DATE, BALANCE
HAVING SUM(BALANCE) >= '1000000.00';
But it is only returning a single record for ID 444 where the account 1 balance is = 1M.
How can I get the query to SUM accounts 1 and 2 for each member and return if over 1M?
New to SQL. Please let me know if I need to add more information.
Thanks in advance