分组函数触发了ORA-00600错误,请大家支招
SELECT B.ID,B.KID(
SELECT A.ID,A.KID,ROW_NUMBER() OVER(PARTITION BY A.ID ORDER BY A.BEGINDATE DESC) AS XH
FROM T_BANK_DKDATA A) B WHERE B.XH=1
如上SQL,是否有其它更好的方法实现?请赐教。
[解决办法]
你的SQL少了个FROM 吧
应该为这样吧:
SELECT B.ID, B.KID
from (SELECT A.ID,
A.KID,
ROW_NUMBER() OVER(PARTITION BY A.ID ORDER BY A.BEGINDATE DESC) AS XH
FROM T_BANK_DKDATA A) B
WHERE B.XH = 1;
select b.id, a.kid
from t_bank_dkdata a,
(select a.id, max(a.begindate) xh from t_bank_dkdata a group by a.id) b
where b.id = a.id
and b.xh = a.begindate