SELECT CAST (330/60 AS FLOAT) AS result
or
SELECT CONVERT(FLOAT, 330/60) AS result
Actually I am expecting result as 5.5
But it is returning 5. Why?
And tell me any solution to get result as 5.5
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
60.0to force fixed-point types:The calculation of
330/60is done as integers which will round the result. After that you cast to float. You can use a numeric type right from the beginnging and don’t need to cast: