请帮助我,我得到了以下sql的Join Predicate无效错误,它会非常混乱,但如果可以,请帮助我。提前谢谢。
SELECT department.eaaitm,
RIGHT(LEFT(egacdt, 6), 2),
SUM(CASE department.eaaitm
WHEN '912' THEN egacam / 2
ELSE egacam
END) AS suma,
SUM(CASE department.eaaitm
WHEN '700' THEN CASE data.eaaicl
WHEN '400' THEN -egacam
WHEN '402' THEN -egacam
WHEN '404' THEN -egacam
ELSE egacam
END
WHEN '912' THEN egacam / 2
ELSE egacam
END / cuarat)
FROM mvxcdtpusd.fchacc department,
mvxcdtpusd.fchacc data
LEFT JOIN mvxcdtpusd.fgledg
ON data.eaaitm = egait1
AND data.eacono = 888
AND data.eaaitp = 1
AND egcono = 888
AND ( egdivi = ?
AND ( data.eadivi = ?
OR data.eadivi = '' ) )
AND ( egdivi = ?
AND ( department.eadivi = ?
OR department.eadivi = '' ) )
AND egacdt >= ?
AND egacdt <= ?
JOIN mvxcdtpusd.ccurra
ON ( cudivi = ( CASE egdivi
WHEN '300' THEN egdivi
ELSE '100'
END )
AND cucucd = 'USD'
AND LEFT(cucutd, 6) = LEFT(egacdt, 6)
AND ( ( cudivi = '300'
AND cucrtp = '50' )
OR ( cudivi <> '300'
AND culocd = 'USD'
AND cucrtp = '1' ) )
AND RIGHT(cucutd, 2) = '01' )
WHERE egait3 = department.eaaitm
AND department.ealccd IN ( 0, 1 )
AND department.eacono = 888
AND department.eaaitp = 3
AND data.eaaicl >= '400'
AND ( department.eaaitm IN ( '000' )
OR department.eaaitm IN ( '912' )
AND data.eaaitm NOT IN ( '5707310' )
OR department.eaaitm IN ( '914', '808' )
AND data.eaaitm NOT IN ( '5707310' ) )
GROUP BY department.eaaitm,
RIGHT(LEFT(egacdt, 6), 2)
ORDER BY department.eaaitm,
RIGHT(LEFT(egacdt, 6), 2)
-----------------------------------答案:---------- ------------------------- 我已经解决了。全部谢谢
SELECT department.eaaitm,
RIGHT(LEFT(egacdt, 6), 2),
SUM(CASE department.eaaitm
WHEN '912' THEN egacam / 2
ELSE egacam
END) AS suma,
SUM(CASE department.eaaitm
WHEN '700' THEN CASE data.eaaicl
WHEN '400' THEN -egacam
WHEN '402' THEN -egacam
WHEN '404' THEN -egacam
ELSE egacam
END
WHEN '912' THEN egacam / 2
ELSE egacam
END / cuarat)
FROM mvxcdtpusd.fchacc department,
mvxcdtpusd.fchacc data
LEFT JOIN mvxcdtpusd.fgledg
ON data.eaaitm = egait1
AND data.eacono = 888
AND data.eaaitp = 1
AND egcono = 888
AND ( egdivi = 100
AND ( data.eadivi = 100
OR data.eadivi = '' ) )
AND egacdt >= 20120101
AND egacdt <= 20120131
JOIN mvxcdtpusd.ccurra
ON ( cudivi = ( CASE egdivi
WHEN '300' THEN egdivi
ELSE '100'
END )
AND cucucd = 'USD'
AND LEFT(cucutd, 6) = LEFT(egacdt, 6)
AND ( ( cudivi = '300'
AND cucrtp = '50' )
OR ( cudivi <> '300'
AND culocd = 'USD'
AND cucrtp = '1' ) )
AND RIGHT(cucutd, 2) = '01' )
WHERE egait3 = department.eaaitm
AND department.ealccd IN ( 0, 1 )
AND department.eacono = 888
AND department.eaaitp = 3
AND data.eaaicl >= '400'
AND ( department.eaaitm IN ( '000' )
OR department.eaaitm IN ( '912' )
AND data.eaaitm NOT IN ( '5707310' )
OR department.eaaitm IN ( '914', '808' )
AND data.eaaitm NOT IN ( '5707310' ) )
AND ( egdivi = 100
AND ( department.eadivi = 100
OR department.eadivi = '' ) )
GROUP BY department.eaaitm,
RIGHT(LEFT(egacdt, 6), 2)
ORDER BY department.eaaitm,
RIGHT(LEFT(egacdt, 6), 2)
答案 0 :(得分:0)
我不确定您使用什么系统将参数传递给查询但我想它会替换下面显示的问号(?)
AND ( egdivi = ?
AND ( data.eadivi = ?
OR data.eadivi = '' ) )
AND ( egdivi = ?
AND ( department.eadivi = ?
OR department.eadivi = '' ) )
AND egacdt >= ?
AND egacdt <= ?
无论如何,你得到的错误是因为其中一个是不对的。请说明如何将参数传递给此查询。