nik*_*hil 1 sql oracle syntax-error
我有一个相对简单的SQL查询拒绝在sqldeveloper上执行,我已经缩小了对此的违规行 -
and (b.date_updated > (sysdate MINUS 2) or a.date_updated > (sysdate MINUS 2))
Run Code Online (Sandbox Code Playgroud)
这是我的where条款的一部分以及其他陈述.
我在视觉上多次对括号进行了计算,它看起来与我平衡,我不确定我在这里做错了什么,有人可以帮我弄清楚这里有什么问题.
为了完整性,这是where子句的样子
where a.customer_id = b.customer_id
and (b.date_updated > (sysdate MINUS 2) or a.date_updated > (sysdate MINUS 2))
and a.c_id = c.c_id
Run Code Online (Sandbox Code Playgroud)
MINUS是一个集合运算符,它在两个集合上运行,基本上是什么UNION或者UNION ALL做什么的"相反" .
要从日期(或其他数字)中减去一个数字,请使用 -
这在Oracle手册的"算术运算符"一章中有记录:https:
//docs.oracle.com/cd/E11882_01/server.112/e41084/operators002.htm#SQLRF51156
您将其与SET运算符混淆:https:
//docs.oracle.com/cd/E11882_01/server.112/e41084/operators005.htm#SQLRF51164
要了解为什么 current_date - 2实际上符合您的预期,请阅读" 日期时间/间隔算术 " 一章:https:
//docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements001.htm#i48042