Home > Back-end >  How would I change this select statement so that it formats as a currency with commas
How would I change this select statement so that it formats as a currency with commas

Time:09-23

SELECT sv.PARENTACCOUNT as 'Account Number'
, sum(case when BALANCECHANGE >0 then BALANCECHANGE else 0 end) as 'Total Credits'
, sum(case when BALANCECHANGE<0 then BALANCECHANGE else 0 end) as 'Total Debits'

How would I change this select statement so that it formats as a currency with commas. I would like the sums to be currency

CodePudding user response:

https://database.guide/how-to-format-numbers-as-currency-in-sql-server-t-sql/

SELECT sv.PARENTACCOUNT as 'Account Number'
, format( sum(case when BALANCECHANGE >0 then BALANCECHANGE else 0 end),'c')  as 'Total Credits'
, format(sum(case when BALANCECHANGE<0 then BALANCECHANGE else 0 end),'c')  as 'Total Debits'
  • Related