求解决:DB2 SQL Error: SQLCODE=-413, SQLSTATE=22003, SQLERRMC=null, DRIVER=3.50.152
withT(A,B,C,D,E)AS(selecta,b,c,d,efroma..),T2(RA,RB,RC,RD,RE)as(selectA,B,C,D,EfromTw...
with T(A,B,C,D,E)
AS
(
select a,b,c,d,e from a ..
)
,
T2(RA,RB,RC,RD,RE)
as
(
select A,B,C,D,E from T where T.E = 1
union all
select T2.RA,T2.RB,
T2.RC || ',' || T.C ,
T2.RD || ',' || T.D ,
T.E
from T ,T2 where T.E = T2.RE +1 AND T.A = T2.RA AND T.B = T2.RB
)
SELECT RA,RB,RC,RD,ROW_NUMBER() OVER(PARTITION BY RA,RB ORDER BY RE DESC) AS RN FROM T2;
最后一个SQL这边ROW_NUMBER报错,这是为啥,解决方法是什么?
或者改成SELECT count(1) FROM T2;也报这个错。。。 展开
AS
(
select a,b,c,d,e from a ..
)
,
T2(RA,RB,RC,RD,RE)
as
(
select A,B,C,D,E from T where T.E = 1
union all
select T2.RA,T2.RB,
T2.RC || ',' || T.C ,
T2.RD || ',' || T.D ,
T.E
from T ,T2 where T.E = T2.RE +1 AND T.A = T2.RA AND T.B = T2.RB
)
SELECT RA,RB,RC,RD,ROW_NUMBER() OVER(PARTITION BY RA,RB ORDER BY RE DESC) AS RN FROM T2;
最后一个SQL这边ROW_NUMBER报错,这是为啥,解决方法是什么?
或者改成SELECT count(1) FROM T2;也报这个错。。。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询