I am writing a query for a report that reads a table containing receipts and gives totals by payment type:
This produces a line for each payment type, but how would one rollup the credit card values ("A","D",'V") into one entry?
Code:
SELECT CASE
WHEN payment_type_an = 'A' THEN 'AMEX '
WHEN payment_type_an = 'C' THEN 'CASH/CHECK '
WHEN payment_type_an = 'D' THEN 'DISCOVER '
WHEN payment_type_an = 'E' THEN 'ECHECK '
WHEN payment_type_an = 'M' THEN 'MONEY ORDER'
WHEN payment_type_an = 'V' THEN 'VISA '
WHEN payment_type_an IS NULL THEN 'UNKNOWN'
END "PT",
COUNT (*) "COUNT",
SUM (total_application_services_amt) "SUM"
FROM closeout_detail
WHERE processor_source = in_rec.PROCESSOR_SOURCE
AND proc_file_seq_nbr = in_rec.PROC_FILE_SEQ_NBR
GROUP BY payment_type_an
ORDER BY payment_type_an;