SQL: remainder of a division

eddys -  
 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)

4 réponses

SuperGolgoth
 
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 ???
1
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.
0
eddys
 
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.
0
NOUR
 
For those interested, it's like this:
number1 mod number2 to get the remainder of the division
- on SQL Server 2000 the MOD function is for example ( X % Y)
0
le pavé dans la mare
 
the remainder is whole, your .4 is fractional
(note: .4 * 5 => 2)
0