Where子句是否有整数范围?

zmi*_*che 9 sql oracle

我需要检查where子句在整数范围内的表达式结果.

点赞这个:

select * from table where (col1 / col2 ) in (1..8). 
Run Code Online (Sandbox Code Playgroud)

随着(1..8)表示整数范围.

我的意思是它必须是整数,而不是浮点数.所以我不能使用between 1 and 8,因为1.2将是正确的.

Ton*_*ews 10

你当然可以这样做:

select * from table where (col1 / col2 ) in (1,2,3,4,5,6,7,8);
Run Code Online (Sandbox Code Playgroud)

要么

select * from table where (col1 / col2 ) between 1 and 8
and mod (col1 , col2 ) = 0;
Run Code Online (Sandbox Code Playgroud)