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?
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:
or Cast the integer o a decimal – i.e.