SQLTeam.com | Weblogs | Forums

Need SQL RESULTS IN 0.00 format (2 decimal places)


sql syntax to get my int value in format 0.00

the sql syntax i have is select colum 1, avg(column2) / cast(sum(cloumn3 as decimal (5,2)) from TABLE X. however my results end up in format 0.000000


cast(avg(column2) / cast(sum(cloumn3 as decimal (5,2)) as decimal(5, 2))

Depending on the datatype of column3, you may be able to skip the CAST of the column SUM.



Usually better to do any formatting at the Client end, in particular if you wind up converting to CHAR in SQL to get the format you want, because then the Client end gets a CHAR instead of a Number/Date/whatever (in native format) and then cannot do anything further with it - without parsing it back again which, particularly with things like Dates, is fraught with side effects ...