Link to home
Start Free TrialLog in
Avatar of Castlewood
Castlewood

asked on

How to set decimal in the result of SQL SELECT ?

I need to have two decimals in the result from the SELECT but I found it always gives me in integer. Even I use CAST it still doesn't refect the fraction. For example,

SELECT CAST(10/3 AS decimal(5,2))
will give 3.00 instead of 3.33.

Basically I tried to get an average days by
SELECT CAST(tot_days/ct AS decimal(5,2)) as avg_days from tab1

Can you tell me how to get the result in proper decimals?
ASKER CERTIFIED SOLUTION
Avatar of Daniel Wilson
Daniel Wilson
Flag of United States of America 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