Link to home
Start Free TrialLog in
Avatar of Scott Baldridge
Scott Baldridge

asked on

Help with query

Hello, I have the following example data where I need the result set to look like this

Branch ID | Deposit Total | Loan Total | Other Total

    1                  2694.00            1238.00          3324.00    

What is the best method to accomplish this task using the example data below?


CREATE TABLE #Data
(
       AccountID int NOT NULL PRIMARY KEY
      ,BranchID int NOT NULL
      ,AccountBalance money NULL
      ,ProductType varchar(10) COLLATE DATABASE_DEFAULT NOT NULL
)

insert #Data(AccountID, BranchId, AccountBalance, ProductType) values (1, 1, 1000.00, 'Loan')
insert #Data(AccountID, BranchId, AccountBalance, ProductType) values (2, 1, 238.00, 'Loan')
insert #Data(AccountID, BranchId, AccountBalance, ProductType) values (3, 2, 566.05, 'Loan')

insert #Data(AccountID, BranchId, AccountBalance, ProductType) values (4, 1, 2583.00, 'Deposit')
insert #Data(AccountID, BranchId, AccountBalance, ProductType) values (5, 1, 111.00, 'Deposit')
insert #Data(AccountID, BranchId, AccountBalance, ProductType) values (6, 3, 200.00, 'Deposit')


insert #Data(AccountID, BranchId, AccountBalance, ProductType) values (7, 1, 22.00, 'Other')
insert #Data(AccountID, BranchId, AccountBalance, ProductType) values (8, 1, 3258.00, 'Other')
insert #Data(AccountID, BranchId, AccountBalance, ProductType) values (9, 1, 44.00, 'Other')
ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Scott Baldridge
Scott Baldridge

ASKER

Yes, this will work great! Thank you!