Integer division in sql server

In the first you are getting the result of two integers and then casting the result as DECIMAL(9,2). In the second you’re just dividing two integers and that’s expected.

If you cast one of the integers as a decimal BEFORE you do the division, you’ll get a decimal result.

SELECT 151/CAST(6 AS DECIMAL (9,2))

Leave a Comment