Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Division

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-01-13 : 08:12:13
Mala writes "Hi ,

Please have a look at the following example.
create table TEST
(VAL1 decimal(20,2),
val2 decimal(10,2))


insert into test
values(10,100)

select val1/val2 as val from test

val
-----------------------------------
.1000000000000


select 10/100 val1 ,val1/val2 val2 from test
val1 val2
----------- -----------------------------------
0 .1000000000000

Why do we get result like this in sql.

Regards,
Mala"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-01-13 : 08:16:25
Integer arithmetic. SELECT 10/100 will give zero because integers do not contain decimals. SELECT 10.0/100.0 will give you 0.1 as a result because the .0 casts the numbers as float datatype.
Go to Top of Page
   

- Advertisement -