【发布时间】:2023-03-12 03:50:01
【问题描述】:
我有如下三张表:
测试
+--------------+--------+
| Test_Case_ID | Status |
+--------------+--------+
| 10 | PASS |
| 20 | FAIL |
| 30 | FAIL |
+--------------+--------+
缺陷
+-----------+
| Defect_ID |
+-----------+
| 500 |
| 400 |
+-----------+
和link1
+--------------+-----------+
| Test_Case_ID | Defect_ID |
+--------------+-----------+
| 20 | 500 |
| 30 | 500 |
| 30 | 400 |
+--------------+-----------+
我正在尝试以下查询
select
test.test_case_id,
test.status,
case when test.status = 'FAIL' then
(select link1.defect_id
from link1
where
test.test_case_id = link1.test_case_id)
end as defect1_id
from test test
我收到以下错误“错误 12/20/2012 10:05:17 AM 0:00:00.093 Toad for Data Analysts: ORA-01427: single-row subquery returns more than one row 1 78 "
有没有办法从链接表中检索“30”的记录?因为我想显示测试用例 30 由于缺陷 500 和 400 而失败。
非常感谢
【问题讨论】:
-
您的 where 子句在子查询中被颠倒了
-
@BhrugeshPatel 你的意思是应该是
where link1.test_case_id = test.test_case_id。我也试过了,但仍然得到同样的错误。 -
您在链接中有两条记录,Test_Case_ID = 30。您要获取哪个 Defect_ID?