SUM based on column value change

Hello, I am trying to calculate a SUM based on a change in Account number. For example, a bank has a branch with 2 accounts. Each account has individual members with individual checking and savings accounts.

So instead of returning each individual SUM of the account name and member number, I want to SUM
based on each change in Account name.

I am having trouble with calculating the SUM based on each change of the Account Name

For example I am looking to SUM the Checking totals and Savings totals for Account 12345 and 44444. Which would include the 8 members of Account 12345 and the 7 Members of Account 44444.

|AccountA|Member Number|Checking|Savings|


|Return SUM||||

|Return SUM > $9000.00||||

So basically return the total based on each account Name and Group those together.
In my table, the Account Name and Member number are in different columns.

Then, from that SUM, I want to only return those records that have Savings > $9000.00

Thank you in advance.

Maybe this?

select AccountA, sum(Savings)
  from #bank
  group by AccountA
  having sum(Savings) > 9000.00
1 Like