Oracle SQL IN 子句使用 Subselect 抛出错误
Oracle SQL IN-Clause throws Error with Subselect
所以这是我的问题:
我得到了这个 SQL-声明
SELECT a.ID,a.CONTENTOF
FROM MLMDATA.PV_STORAGE a
WHERE 1=1
AND ID IN (113312,114583,114581,113472,114585,114580,113314)
AND a.SEQ = (SELECT MAX(b.SEQ) FROM MLMDATA.PV_STORAGE b where a.ID = b.ID)
但我现在的问题是,我遇到了一个错误:
ORA-00600: Internal Error Code, Arguments: [qernsRowP], [1], [], [], [], [], [], [], [], [], [], []
我似乎无法找到 select 这些 ID 的方法,其中只有最高的 SEQUENZE 是 selected....
我已经创建了一个视图,只显示了最高的 SEQ,但这对八点不起作用......
我有点沮丧,因为据我所知,SQL 以前工作过,但突然不工作了。
有人知道问题出在哪里吗?
请尝试这个查询:
SELECT a.ID,a.CONTENTOF FROM MLMDATA.PV_STORAGE a
INNER JOIN
(SELECT ID, CONTENTOF, MAX(SEQ) AS SEQ FROM MLMDATA.PV_STORAGE
where ID IN (113312,114583,114581,113472,114585,114580,113314)
GROUP BY ID, CONTENTOF) b
ON a.id = b.id AND a.SEQ = b.SEQ
试试 window 函数:
select id, contentof
from (
select id, contentof,
row_number() over (partition by id order by seq desc) as rn
FROM MLMDATA.PV_STORAGE a
where id IN (113312,114583,114581,113472,114585,114580,113314)
)
where rn = 1;
所以这是我的问题: 我得到了这个 SQL-声明
SELECT a.ID,a.CONTENTOF
FROM MLMDATA.PV_STORAGE a
WHERE 1=1
AND ID IN (113312,114583,114581,113472,114585,114580,113314)
AND a.SEQ = (SELECT MAX(b.SEQ) FROM MLMDATA.PV_STORAGE b where a.ID = b.ID)
但我现在的问题是,我遇到了一个错误:
ORA-00600: Internal Error Code, Arguments: [qernsRowP], [1], [], [], [], [], [], [], [], [], [], []
我似乎无法找到 select 这些 ID 的方法,其中只有最高的 SEQUENZE 是 selected.... 我已经创建了一个视图,只显示了最高的 SEQ,但这对八点不起作用...... 我有点沮丧,因为据我所知,SQL 以前工作过,但突然不工作了。
有人知道问题出在哪里吗?
请尝试这个查询:
SELECT a.ID,a.CONTENTOF FROM MLMDATA.PV_STORAGE a
INNER JOIN
(SELECT ID, CONTENTOF, MAX(SEQ) AS SEQ FROM MLMDATA.PV_STORAGE
where ID IN (113312,114583,114581,113472,114585,114580,113314)
GROUP BY ID, CONTENTOF) b
ON a.id = b.id AND a.SEQ = b.SEQ
试试 window 函数:
select id, contentof
from (
select id, contentof,
row_number() over (partition by id order by seq desc) as rn
FROM MLMDATA.PV_STORAGE a
where id IN (113312,114583,114581,113472,114585,114580,113314)
)
where rn = 1;