ORACLE SQL从2个select语句中获取两个值的差异

我们有2个非常简单的SELECT语句:

SELECT value from table where date between DATE1 and DATE2
SELECT value from table where date between DATE3 and DATE4

我们需要一种方法来编写单个SQL语句,它将获得从这两个SQL语句返回的“值”的差异.

我们尝试了以下但是没有成功:

SELECT value from table where date between DATE1 and DATE2
minus 
SELECT value from table where date between DATE3 and DATE4

任何建议都非常感谢.

未经测试但应该工作:

SELECT
    (SELECT value from table where date between DATE1 and DATE2) - 
    (SELECT value from table where date between DATE3 and DATE4)
FROM dual;

假设您的SELECT值保证返回单个值

相关文章
相关标签/搜索