我第一次在SEQUEL VIEWPOINT上工作,我创建了这个查询,我有AcctNo。作为派生领域。
SELECT Cat(substr(cat("000",digits(i0nrov.cbi0rep)),length(cat("000",digits(i0nrov.cbi0rep)))-2,3),substr(cat("000000000",digits(i0cnbr.cbi0rep)),length(cat("000000000",digits(i0cnbr.cbi0rep)))-8,9))NAME(Acctno) COLHDG("Accnt Number"),
i0cnbr.cbi0rep NAME(PreAccNo) COLHDG("Pre Accnt Num" "Number"),
i0cnbr.cbi0repres NAME(PostAccNo) COLHDG("Post Accnt Num" "Number"),
SUM(i0a01) NAME(PreARBal) COLHDG(" Pre A/R Bal ") EDTCDE(L), SUM(i0a01) NAME(PostARBal) COLHDG("Post A/R Bal") EDTCDE(L)
FROM bakbosfile/cbi0rep,auditsql/xrfcmpfres,auditsql/cbi0repres
INNER JOIN Acctno=cxgcus.xrfcmpfres and cxcnbr.xrfcmpfres=i0cnbr.cbi0repres
GROUP BY Acctno,PreAccNo,PostAccNo
HAVING SUM(I0A01.cbi0rep)<>SUM(I0A01.cbi0repres)
UNION ALL
SELECT Cat(substr(cat("000",digits(i0nrov.cbi0rep)),length(cat("000",digits(i0nrov.cbi0rep)))-2,3),substr(cat("000000000",digits(i0cnbr.cbi0rep)),length(cat("000000000",digits(i0cnbr.cbi0rep)))-8,9))NAME(Acctno) COLHDG("Accnt Number"),
i0cnbr.cbi0rep NAME(PreAccNo) COLHDG("Pre Accnt Num" "Number"),
i0cnbr.cbi0repbus NAME(PostAccNo) COLHDG("Post Accnt Num" "Number"),
SUM(i0a01) NAME(PreARBal) COLHDG(" Pre A/R Bal ") EDTCDE(L), SUM(i0a01) NAME(PostARBal) COLHDG("Post A/R Bal") EDTCDE(L)
FROM bakbosfile/cbi0rep,auditsql/xrfcmpfbus,auditsql/cbi0repbus
INNER JOIN Acctno=cxgcus.xrfcmpfbus and cxcnbr.xrfcmpfbus=i0cnbr.cbi0repbus
GROUP BY Acctno,PreAccNo,PostAccNo
HAVING SUM(I0A01.cbi0rep)<>SUM(I0A01.cbi0repbus)
请帮忙!我收到以下错误:
Hello Buck感谢您的回复,但它没有在声明中识别出2 JOIN,所以我将查询更改为:
SELECT Cat(substr(cat("000",digits(i0nrov.cbi0rep)),length(cat("000",digits(i0nrov.cbi0rep)))-2,3),substr(cat("000000000",digits(i0cnbr.cbi0rep)),length(cat("000000000",digits(i0cnbr.cbi0rep)))-8,9)) NAME(Acctno) COLHDG("Accnt Number"),
i0cnbr.cbi0rep NAME(PreAccNo) COLHDG("Pre Accnt Num" "Number"), i0cnbr.cbi0repres NAME(PostAccNo) COLHDG("Post Accnt Num" "Number"),
SUM(i0a01) NAME(PreARBal) COLHDG(" Pre A/R Bal ") EDTCDE(L), SUM(i0a01) NAME(PostARBal) COLHDG("Post A/R Bal") EDTCDE(L)
FROM bakbosfile/cbi0rep,auditsql/xrfcmpfres, auditsql/cbi0repres
INNER JOIN Cat(substr(cat("000",digits(i0nrov.cbi0rep)),length(cat("000",digits(i0nrov.cbi0rep)))-2,3),substr(cat("000000000",digits(i0cnbr.cbi0rep)),length(cat("000000000",digits(i0cnbr.cbi0rep)))-8,9))
=cxgcus.xrfcmpfres AND cxcnbr.xrfcmpfres=i0cnbr.cbi0repres
GROUP BY Acctno,PreAccNo,PostAccNo
HAVING SUM(I0A01.cbi0rep)<>SUM(I0A01.cbi0repres)
但是得到错误:
答案 0 :(得分:0)
如果这是针对DB2 for i的,那么典型的语法是:
SELECT Cat(substr(cat("000",digits(i0nrov.cbi0rep)),length(cat("000",digits(i0nrov.cbi0rep)))-2,3),substr(cat("000000000",digits(i0cnbr.cbi0rep)),length(cat
("000000000",digits(i0cnbr.cbi0rep)))-8,9)) as acctno, ...
FROM bakbosfile/cbi0rep
JOIN auditsql/xrfcmpfres on Cat(substr(cat("000",digits(i0nrov.cbi0rep)),length(cat("000",digits(i0nrov.cbi0rep)))-2,3),substr(cat("000000000",digits(i0cnbr.cbi0rep)),length(cat
("000000000",digits(i0cnbr.cbi0rep)))-8,9))=cxgcus.xrfcmpfres
JOIN auditsql/cbi0repres on cxcnbr.xrfcmpfres=i0cnbr.cbi0repres
IBM文档位于Knowledge Center。您没有提到要连接的IBM i版本,因此here is an elderly DB2 for I reference。