I have built a select query which utilises the SUM function and I’m trying to make the output show with 2 decimal places for the Settlement amount. In this example the actual STTL_AMOUNT is 29999 but I’d like it to output 299.99 so I need to add a decimal place in before the last 2 numbers. The format for STTL_AMOUNT is number(22,4)
SELECT COUNT (STTL_AMOUNT) as "COUNT",
SUM(STTL_AMOUNT) - SUM(CASE WHEN IS_REVERSAL =1 THEN STTL_AMOUNT ELSE 0 End ) as "Settlement Amount",
HOST_DATE as "Settlement Date"
FROM OPR_OPERATION
WHERE MCC = '6011'
AND MSG_TYPE ='MSGTPRES'
AND HOST_DATE >= TRUNC( SYSDATE )
GROUP BY HOST_DATE;
And I get the output below:
"COUNT" "Settlement Amount" "Settlement Date"
1 29999 24-MAY-24
But I would like it to output as this:
"COUNT" "Settlement Amount" "Settlement Date"
1 299.99 24-MAY-24
I was wondering if I should use to_char but can’t seem to get the query to work at all if I try that. Any help would be much appreciated.