troubleshooting Question

Help with query

Avatar of Scott Baldridge
Scott Baldridge asked on
Microsoft SQL Server
2 Comments1 Solution208 ViewsLast Modified:
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
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros