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

Klos, Susan Susan.Klos at fldoe.org
Wed Aug 4 10:53:52 CDT 2004


Thank you, Stuart.  That was exactly what I was looking for.  I thought I
had to use cast but I hadn't seen float anywhere in my research.

Susan Klos
Senior Database Analyst
Evaluation and Reporting
Florida Department of Education
850-245-0708 
sc 205-0708
 

-----Original Message-----
From: Stuart McLachlan [mailto:stuart at lexacorp.com.pg] 
Sent: Wednesday, August 04, 2004 11:01 AM
To: dba-sqlserver at databaseadvisors.com
Subject: Re: [dba-SQLServer] formatting a number to 2 decimal places.

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.



_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com



More information about the dba-SQLServer mailing list