sql - Oracle SQL中奇怪的缺少右括号错误
问题描述
我有这个where
子句,当我尝试保存它时,会显示“缺少右括号”错误。代码如下:
where
(
(a.date is not null
and sysdate between b.date and b.date2
and b.per_id is not null
group by b.per_id)
or
(a.date is null
and b.per_id is not null
group by b.per_id)
)
这样做的目的是检查何时a.date
仅null
输出满足的值,sysdate between b.date and b.date2
否则何时a.date
仅not null
输出满足的值sysdate not between b.date and b.date2
解决方案
group by
是该子句之后的where
子句。这不是一个条件。
所以你要:
select . . .
from . . .
where (a.date is not null and
sysdate between b.date and b.date2 and
b.per_id is not null
) or
(a.date is null and
b.per_id is not null
)
group by b.per_id
推荐阅读
- mysql - 如何扩展 CI3 $this->db
- php - 第一次 PHP 大学作业 - 使用隐藏值传递参数?
- c# - 具有异步等待的全局互斥锁
- base64 - 使用 node.js 中的 slugId 的 UUID 的 base64 表示
- iis - IIS 上的 URL 重写反向代理仅在其自身的服务器上工作
- swift - 如何在 Swift 中处理多个泛型协议?
- pointers - big.Int 和 *big.Int 之间的区别,以及如何按值传递 big.Int
- python-3.x - 将 CSV 读取为文本文件并将其标记化
- c# - 从 API 调用响应中检索数据?
- sql - T-SQL 结果集 - 包含 3 个表