Link to home
Start Free TrialLog in
Avatar of joygomez
joygomezFlag for United States of America

asked on

SQL unable to place calculation of 1/4 into a column (decimal (18,4)

In Sql Servicer, I am unable to do a calculation of 1/4 and place it in column with decimal (18,4).  However when i place the value .25, it accepts it.

below is the query.

                  UPDATE ExactCostLaborTimings_WorkingTbl_Granular
                  SET         ExactCostLaborTimings_WorkingTbl_Granular.DividingFactor =1/4
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It's probably treating 1 and 4 as integers, losing precision, so the result is rounded to 0.  Adding a decimal, like with 0.25 or 1/4.0 implicitly converts the values to a data type that preserves the fractional number.  You could also use an explicit cast to do the same thing CAST(1 as decimal) / CAST(4 as decimal)
Never mind.  Too late :-)
Avatar of joygomez

ASKER

That was quick! Thank you.