Take the 2-minute tour ×

When I run the query:

select (100/50)

It give me 2 - good.

But when I run the query:

select (50/100)

I was expected it will give me 0.5... but it gives me 0 instead? Why? and How can I get the 0.5?

select (25/(30))*100

I was expected it will give me 83.33 but it also gives 0 instead?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

When you divide two integers, the result is an integer as well, so 50 / 100 is 0.5, which is an integer of 0.

To get a decimal point, either write:

Select 50.0 / 100

or Cast the integer o a decimal - i.e.

share|improve this answer

Try this:

select (50/100.0)

Using an integer for division will lead to zero if the result is less than 1 because integer values can only be round numbers.

0.99 will result in the lower value = 0
3.876 will result in 3 and so on.

Use decimal variables to get the result you want. You can easily do that by using a . in your numbers: 100.0

share|improve this answer

SQL Server considers your numbers as int and gives an int result.


select 100.0/50

select (25.0/(30))*100
share|improve this answer

Your Answer


