In SQL, I have col1 and col2. Both are integers.
I want to do like:
select col1/col2 from tbl1
I get the result 1 where col1=3 and col2=2
The result I want is 1.1
I put round(col1/col2,2). The result is still 1.
I put decimal(col1/col2,2). The decimal is not built in function.
How can I do exactly to get 1.1?
You will need to cast or convert the values to decimal before division. Take a look at this
http://msdn.microsoft.com/en-us/library/aa226054.aspx
For example
The first SELECT will result in what you’re seeing while the second SELECT will have the correct answer
1.500000