Friday, March 30, 2012

How to format numbers in a query

Hey - I have a quick question and know that it is probably pretty simple, but I am stumped. I have a query where I need to make a colum a number that looks like a percent with 2 significant digits:

i.e.,
SELECT tblNumericCovert.number1, tblNumericCovert.number2, [number1]/[number2] AS testDiv
FROM tblNumericCovert

where testDiv needs to spit out results like this ###.##

I am totally lost, if anyone can help, I would appreciate it.select to_char(number1/number2, '99.99') As testDiv from table;|||Originally posted by r123456
select to_char(number1/number2, '99.99') As testDiv from table;

When I do this, I get the error message that "to_char is not a vaild function name'|||What db are you using? to_char works for Oracle, but not SQL server.

Try:

select convert(money, (number1/number2)) As testDiv from tablesql

No comments:

Post a Comment