Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 使用空值进行阈值比较_Sql_Oracle_Threshold - Fatal编程技术网

Sql 使用空值进行阈值比较

Sql 使用空值进行阈值比较,sql,oracle,threshold,Sql,Oracle,Threshold,我们正在构建一个报告,其中一些值与阈值进行比较。逻辑是 if value > lower_threshold and value < upper_threshold then PASS else FAIL if value>lower\u threshold和value

我们正在构建一个报告,其中一些值与阈值进行比较。逻辑是

if value > lower_threshold and value < upper_threshold then PASS else FAIL
if value>lower\u threshold和value
但是,对于某些参数,上限_阈值设置为NULL。这基本上意味着没有上限阈值,如果值下限阈值和值
这不是一个好办法。有没有其他方法可以达到同样的效果?

if value > lower_threshold and (value < upper_threshold or upper_threshold is null) then PASS else FAIL

想到

if value > lower_threshold and (value < upper_threshold or upper_threshold is null) then PASS else FAIL

不完全是你想要的,因为较低的范围是包含的,但是也许你可以考虑语法(需要12.1或更高的时间)。 结果:

select * from demo_ranges as of period for threshold_range 100;

DESCRIPTION          LOWER_THRESHOLD UPPER_THRESHOLD
-------------------- --------------- ---------------
Orange                           100             200

select * from demo_ranges as of period for threshold_range 1000;

DESCRIPTION          LOWER_THRESHOLD UPPER_THRESHOLD
-------------------- --------------- ---------------
Red                              200 

内部构建了与戈登的答案相同的SQL(您可以用“代码> dBMSUntudio.ExpExpQSQLXTEX/<代码>确认”。

不完全是您想要的,因为较低的范围是包含的,但也许您可以考虑语法(需要12.1或更高版本)。

结果:

select * from demo_ranges as of period for threshold_range 100;

DESCRIPTION          LOWER_THRESHOLD UPPER_THRESHOLD
-------------------- --------------- ---------------
Orange                           100             200

select * from demo_ranges as of period for threshold_range 1000;

DESCRIPTION          LOWER_THRESHOLD UPPER_THRESHOLD
-------------------- --------------- ---------------
Red                              200 

在内部,它构建了与Gordon回答中相同的SQL(您可以使用
dbms\u实用程序来确认这一点。展开\u SQL\u text
)。

您的帖子被标记为
SQL
。在哪里使用if语句?SQL中没有这样的东西。您的帖子被标记为
SQL
。在哪里使用if语句?SQL中没有这样的东西。
select * from demo_ranges as of period for threshold_range 100;

DESCRIPTION          LOWER_THRESHOLD UPPER_THRESHOLD
-------------------- --------------- ---------------
Orange                           100             200

select * from demo_ranges as of period for threshold_range 1000;

DESCRIPTION          LOWER_THRESHOLD UPPER_THRESHOLD
-------------------- --------------- ---------------
Red                              200