sql - 检索子查询中导致“单行子查询返回多行”的特定行
问题描述
我有一个查询,其中嵌套子查询引发错误“单行子查询返回多行”。此错误发生在一个环境中。(TEST) 但不是另一个 (STAGE),因为存在一些数据差异。
我需要找出究竟是哪些数据导致了这种情况。但是如何将其重写为 WHERE/HAVING COUNT > 0 查询?子查询是嵌套的。
假设PLANS_T.MANAGER_ID
是我在PERSON_T
下面的子查询中检查的“外部”值。
select * from plans_t p
where
(select inactive_date
from persons.person_t
where
current_flag = 'Y' and
uniqueidentifier = p.manager_id
) is null
这是在甲骨文中。
解决方案
尝试
select inactive_date
from persons.person_t
where
current_flag = 'Y' and
uniqueidentifier in (select p.manager_id from plans_t p)
group by inactive_date
having count(*)>1
推荐阅读
- raku - “要求”在哪里定义?
- sql - 如何提取不同长度的字符串的一部分并将其插入表中?
- python - 无法在 Raspberry pi 上的 StaticText 上设置 bgcolor(但在 Win10 中没有)
- biztalk - BizTalk 映射中的累积和 functoid 忽略小数点后的零
- python - 在 python 控制台中显示汉字
- c++ - 这是一个错误吗?constexpr 构造函数静默变为非 constexpr
- c# - 在c#中锁定sqlcommand对象
- bootstrap-4 - 无法获得下拉菜单的“打开”状态
- xml - 标签的Apache骆驼更改值
- java - 为什么当 Arcore 片段工作时 DrawerLayout 不起作用?