How to get into a report with agregate values, in addition with rollup clausule, based on column from one table only distinct records. The report is a join of two tables because of a need to filter data based on columns present in the second table.
Table1 (BillID, CustomerID, TotalAmount)
Table2 (ItemID, BillID, Price, PriceWithoutDiscount)
SELECT
CustomerID,
SUM(TotalAmount)
FROM
Table1 T1 JOIN
Table2 ON T1.BillID = T2.BillID
WHERE
T2.Price <> T2.PriceWithouDiscount
GROUP BY T1.Customer WITH ROLLUP