i wrong result unsing cast function.it should simple can not figure out. need help.
select prco, employee, lastname, firstname, midname, sortname, ssn, hiredate, datediff(month, hiredate, getdate()) / 12 years, cast((80/2080) decimal(10, 5)) aaaa
80/2080
column should 0.038470
shows 0.00000
records
it's doing division operation before cast. when divide 2 integers result integer, meaning decimal portion truncated. in case, leaves 0
result. 0 cast decimal(10,5)
still 0.00000
.
this should give correct result:
cast((80/2080.0) decimal(10, 5))
Comments
Post a Comment