Have you tried running the following:

SELECT 141.0 / 207.0

Here's what I get -

(ran these statements)
select 141.0 / 207.0
select Convert(float, 141)/Convert(float, 207)

Results:
            
------------
.681159
                                                      
-----------------------------------------------------
0.6811594202898551

Since the result for the integer division (which returns an integer) is < 1
then SQL Server keeps the variable definition at integer and spits out the
integer value of the result, which is 1.  Same thing with your
convert(float, 141/207).  It does the integer division which returns a 0 and
then converts 0 to a float.

Hatton

> -----Original Message-----
> From: John Stanley [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 03, 2004 1:26 PM
> To: CF-Community
> Subject: SOT....OK.....Way OT
>
>  SQL Question: SQL 2000
>  
> Was gonna post this question, but found the answer, so maybe
> it will help someone save some time
>  
> The following:
>     1.    Select 141/207 returns 0
>     2.    Select Convert(float,141/207) returns .00000
>  
> This is because SQL does the math first for the division, and
> apparently treats anything less than one as zero, when the
> dividend and divisor are integers.
>  
> So you need to do this Select Convert(float,141)/Convert(float,207)
>  
> Unless of course the data you are using is already not an integer.
>  
> Have a happy day....
>  
> John
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to