SQL: remainder of a division
eddys
-
JustinFernal -
JustinFernal -
Hi everyone!!!
Is it possible to get the remainder of a division in an SQL statement? How do we do that?
Basically, in my WHERE clause, I want the record to have one of its fields divisible by a value that I enter dynamically
and that the remainder of the division of this field by the entered value is 0...
Thanks in advance :o)
Is it possible to get the remainder of a division in an SQL statement? How do we do that?
Basically, in my WHERE clause, I want the record to have one of its fields divisible by a value that I enter dynamically
and that the remainder of the division of this field by the entered value is 0...
Thanks in advance :o)
4 réponses
SQL2000 ... it poses a problem for me ...
If (X % Y) = the remainder of the division ...
if I take a calculator and I do 12/5, I get 2.4
So if I do select (12 % 5) I should get 4
Then how is it that I get 2 ???
If (X % Y) = the remainder of the division ...
if I take a calculator and I do 12/5, I get 2.4
So if I do select (12 % 5) I should get 4
Then how is it that I get 2 ???
JustinFernal
12 = 5*2 + 2, the remainder of the division is this +2. But 0.4 is indeed equal to 2 divided by 5, there is a connection.
Whoa, sorry for the useless question! I wasn't using the right way of the mod function!
For those who are interested, it's like this:
number1 mod number2 to get the remainder of the division.
For those who are interested, it's like this:
number1 mod number2 to get the remainder of the division.