所以这是我的问题:我得到了这个 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], [], [], [], [], [], [], [], [], [], []
我似乎找不到一种方法来选择这些 ID,其中只选择了最高的 SEQUENZE......我已经创建了一个视图,只显示最高的 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
尝试一个窗口函数:
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;