Link to home
Start Free TrialLog in
Avatar of jeffbarbacpa
jeffbarbacpa

asked on

How to join flat and deep tables in MS SQL Reporting Services

I have one table of loans and another table of transactions that relate to those loans.  I am trying to figure out how to produce a report that shows each loan in the loan table, and corresponding transaction totals.

Loan table:  LOAN_NUM, BORROWER_NAME, FUND_DATE
Transaction Table:  LOAN_NUM, TRANS_TYPE, AMOUNT

Desired output:

LOAN_NUM, BORROWER_NAME, FUND_DATE, SUM OF AMOUNT where trans_type = D, SUM OF AMOUNT where transtype = P

In access, I would create a couple queries and it would be done.  I can't figure out an easy way to do in MS Reporting Services.  Help!
Avatar of Nico Bontenbal
Nico Bontenbal
Flag of Netherlands image

Use a query like this as the source of your report:
Select loan.LOAN_NUM, loan.BORROWER_NAME, loan.FUND_DATE, sum(transaction.AMOUNT) as Total
from loan inner join transaction on loan.LOAN_NUM = transaction.LOAN_NUM
where  transaction.trans_type = 'D'
group by loan.LOAN_NUM, loan.BORROWER_NAME, loan.FUND_DATE

Open in new window

Didn't test it so it might need some tweaking.
Avatar of jeffbarbacpa
jeffbarbacpa

ASKER

what about the sum of 'P' transactions though?  How do I get both 'D' and 'P' in the same query?
ASKER CERTIFIED SOLUTION
Avatar of Nico Bontenbal
Nico Bontenbal
Flag of Netherlands 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