[dba-SQLServer] formatting a number to 2 decimal places.

Stuart McLachlan stuart at lexacorp.com.pg
Wed Aug 4 10:00:35 CDT 2004


On 4 Aug 2004 at 8:31, Klos, Susan wrote:

> 
> SELECT     distenrl, distname, wtgpa1 / EnrlTot AS wgpa
> 

I presume that everything up to here has been integers, so you need to convert 
wtgpa1 to a float before doing the division, otherwise it will use integer 
arithmetic. To round it to one decimal place, you also need to round the result 
of the division.

SELECT distenrl,distname, ROUND(CAST(wtggpa1 AS FLOAT) / ENrlTot, 1 ) as wgpa



 
-- 
Lexacorp Ltd
http://www.lexacorp.com.pg
Information Technology Consultancy, Software Development,System Support.






More information about the dba-SQLServer mailing list