JtheRipper
IS-IT--Management
Hi there,
I have 2 pieces of SQL that I run in Query Analyzer (SQL Server 2005). The first one gives me the correct result - 1.5, the second one not - 1.0.
I stumbled upon this when I was doing something like:
I noticed that it gave me the wrong result ie
3/2 = 1 and not 1.5.
I tried doing a cast/convert but it did not help.
Any ideas ?
Thanks,
J.
I have 2 pieces of SQL that I run in Query Analyzer (SQL Server 2005). The first one gives me the correct result - 1.5, the second one not - 1.0.
Code:
1:
declare @tmp decimal(10,2)
set @tmp=3
set @tmp=@tmp/2
select @tmp
===> 1.5
2:
select 3/2
===> 1.0
I stumbled upon this when I was doing something like:
Code:
select avg(col1) from mytbl.
I noticed that it gave me the wrong result ie
3/2 = 1 and not 1.5.
I tried doing a cast/convert but it did not help.
Any ideas ?
Thanks,
J.