I am trying to use format within an SQL query to suit a reporting package. I have numbers that I need to show as currency with two decimal places so I am using the format command to do that. The problem is that format also puts in a comma to separate thousands and the reporting package sum function cannot handle this so treats the formatted numeric value as text and does not add it in. The query uses:-
SELECT customers.name AS "customers name", FORMAT(contracts.charge,2) AS "contracts charge"
FROM customers
ORDER BY customers.name
(the actual query is a lot more complex but this is the relevant part)
To explain more fully:-
If the numeric value is 123.1 the formatted output is 123.10 which works. If the numeric value is 1234.1 the formatted output is 1,234.10 which does not
I need to find a way to persuade the query to output 1234.10
Many thanks
You could just:
REPLACE(FORMAT(contracts.charge, 2), ',', '')