Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Use sum from tableA as field in tableB report?

I need to create a report that calculates the following for each customer.

tableA.beginbalance - tableA.expenses + sum(tableB.deposits)

tableA has one record per customer. tableB has multiple records for each customer

Not sure how to approach this. I've looked at subreports and using SQL in an Add Command with no luck. I'm using Crystal 9.

Any suggestions?

Mark

Former Member
Former Member replied

You can add the join inside the Command so you don't have to join the Command with the tableA. This worked for an example I made:

SELECT tableA.*, CustomerDeposit.Deposit FROM (SELECT tableB.customer, SUM(tableB.deposits) AS Deposit FROM tableB GROUP BY tableB.customer) AS CustomerDeposit INNER JOIN tableA ON tableA.customer = CustomerDeposit.customer

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question