The following piece of code is resulting in a value with 4 decimals.
COALESCE (SUM( CASE WHEN PLL_TRANSACTIONTYPE = 'TAX' and PLL_REVENUETYPE = 'OTHER' then CAST(ROUND(PLL_AMOUNT,2) as decimal (9,2))
WHEN PLL_REVENUETYPE = 'TAX' THEN CAST(ROUND(PLL_TAXAMOUNT,2) as decimal (9,2))
WHEN PLL_ISINCLUSIVETAX = '-' THEN CAST(ROUND(PLL_NETAMOUNT,2) as decimal (9,2))
ELSE CAST(ROUND(PLL_NETAMOUNT,2)as decimal (9,2)) END ), 0) * -1.00 AS AMOUNT
I found many suggestions on the web, but I haven't been able to round the amount with 2 decimals.
Also, when I do a SQMCMD to export the query to a CSV, it will drop the leading zero if the amount is 0.00
Any help would be appreciated.