SELECT SQL multiple of N
I need a little help, I have the following situation:
SELECT MULTI, N FROM TABLE;
Selection result:
MULTI N
14 5
13 10
13 10
5 5
14 7
In this case, I only want what matches this:
if (N % MULTI == 0)
, therefore 5
and 5
will be valid 7
and 14
also.
I don't know how to do this in mine WHERE
. Hope you can help me here. Many thanks!
+3
Rguy
source
to share
2 answers
You can use MOD as shown below
SELECT MULTI, N
FROM TAB
WHERE MOD(MULTI,N) = 0;
Demo SqlFiddle
+1
Parado
source
to share
In Oracle, you can use mod.
select MULTI,N,
CASE
WHEN mod(N,MULTI)=0 THEN
'VALID'
ELSE
'INVALID'
END AS MOD_TES
from TABLE
0
Benedict E. Pranata
source
to share