У меня были некоторые проблемы с отчетом по SSRS, который я пытаюсь параметризовать. Объявления параметров и запрос верны, я знаю это, потому что он работает в Query Reporter.
Параметры объявляются в разделе параметров набора данных (а также в самом отчете), я знаю, что параметры Oracle используются с двоеточием (:) вместо знака (@). База данных, которую мы используем, - Oracle 9i.
ERROR
Сначала у меня был отчет с подключением OleDB, и он просто выдал ошибку, говорящую:
"Произошла ошибка во время локальной обработки отчета. Сервер не
дал значительный ответ, причиной может быть не соответствующий контракт,
преждевременное завершение сеанса или внутренняя ошибка сервера. "
После некоторых исследований я обнаружил, что соединение с OleDB вызывало такого рода проблемы при использовании того же имени параметра в запросе. Например: "SELECT * FROM table WHERE :param > 0 AND :param < 10;"
Поэтому я решил попробовать с подключением ODBC. После этого он перестанет показывать вышеуказанное сообщение об ошибке и вместо этого покажет:
"ORA-01008: не все переменные связаны."
QUERY
Этот запрос используется в наборе данных.
SELECT Trim(a.acct_segment1)||' - '||trim(b.cctre_seg_name) AS col1,
Trim(a.acct_segment2)||' - '||trim(c.cctre_seg_name) AS col2,
Trim(a.acct_segment3)||' - '||Trim(h.exp_ele_desc) AS col3,
CASE WHEN :month = '01' THEN Sum(e.amount_itemx1)
WHEN :month = '02' THEN Sum(e.amount_itemx2)
WHEN :month = '03' THEN Sum(e.amount_itemx3)
WHEN :month = '04' THEN Sum(e.amount_itemx4)
WHEN :month = '05' THEN Sum(e.amount_itemx5)
WHEN :month = '06' THEN Sum(e.amount_itemx6)
WHEN :month = '07' THEN Sum(e.amount_itemx7)
WHEN :month = '08' THEN Sum(e.amount_itemx8)
WHEN :month = '09' THEN Sum(e.amount_itemx9)
WHEN :month = '10' THEN Sum(e.amount_itemx10)
WHEN :month = '11' THEN Sum(e.amount_itemx11)
WHEN :month = '12' THEN Sum(e.amount_itemx12) END AS col4,
CASE WHEN :month = '01' THEN Sum(i.amount_itemx1)
WHEN :month = '02' THEN Sum(i.amount_itemx2)
WHEN :month = '03' THEN Sum(i.amount_itemx3)
WHEN :month = '04' THEN Sum(i.amount_itemx4)
WHEN :month = '05' THEN Sum(i.amount_itemx5)
WHEN :month = '06' THEN Sum(i.amount_itemx6)
WHEN :month = '07' THEN Sum(i.amount_itemx7)
WHEN :month = '08' THEN Sum(i.amount_itemx8)
WHEN :month = '09' THEN Sum(i.amount_itemx9)
WHEN :month = '10' THEN Sum(i.amount_itemx10)
WHEN :month = '11' THEN Sum(i.amount_itemx11)
WHEN :month = '12' THEN Sum(i.amount_itemx12) END AS col5,
CASE WHEN :month = '01' THEN Sum(d.amount_itemx1)
WHEN :month = '02' THEN Sum(d.amount_itemx2)
WHEN :month = '03' THEN Sum(d.amount_itemx3)
WHEN :month = '04' THEN Sum(d.amount_itemx4)
WHEN :month = '05' THEN Sum(d.amount_itemx5)
WHEN :month = '06' THEN Sum(d.amount_itemx6)
WHEN :month = '07' THEN Sum(d.amount_itemx7)
WHEN :month = '08' THEN Sum(d.amount_itemx8)
WHEN :month = '09' THEN Sum(d.amount_itemx9)
WHEN :month = '10' THEN Sum(d.amount_itemx10)
WHEN :month = '11' THEN Sum(d.amount_itemx11)
WHEN :month = '12' THEN Sum(d.amount_itemx12) END AS col6,
CASE WHEN :month = '01' THEN Sum(e.amount_itemx1 - i.amount_itemx1 - d.amount_itemx1)
WHEN :month = '02' THEN Sum(e.amount_itemx2 - i.amount_itemx2 - d.amount_itemx2)
WHEN :month = '03' THEN Sum(e.amount_itemx3 - i.amount_itemx3 - d.amount_itemx3)
WHEN :month = '04' THEN Sum(e.amount_itemx4 - i.amount_itemx4 - d.amount_itemx4)
WHEN :month = '05' THEN Sum(e.amount_itemx5 - i.amount_itemx5 - d.amount_itemx5)
WHEN :month = '06' THEN Sum(e.amount_itemx6 - i.amount_itemx6 - d.amount_itemx6)
WHEN :month = '07' THEN Sum(e.amount_itemx7 - i.amount_itemx7 - d.amount_itemx7)
WHEN :month = '08' THEN Sum(e.amount_itemx8 - i.amount_itemx8 - d.amount_itemx8)
WHEN :month = '09' THEN Sum(e.amount_itemx9 - i.amount_itemx9 - d.amount_itemx9)
WHEN :month = '10' THEN Sum(e.amount_itemx10 - i.amount_itemx10 - d.amount_itemx10)
WHEN :month = '11' THEN Sum(e.amount_itemx11 - i.amount_itemx11 - d.amount_itemx11)
WHEN :month = '12' THEN Sum(e.amount_itemx12 - i.amount_itemx12 - d.amount_itemx12) END AS col7,
CASE WHEN :month = '01' THEN Sum(e.amount_itemx1)
WHEN :month = '02' THEN Sum(e.amount_itemx1 + e.amount_itemx2)
WHEN :month = '03' THEN Sum(e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3)
WHEN :month = '04' THEN Sum(e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4)
WHEN :month = '05' THEN Sum(e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5)
WHEN :month = '06' THEN Sum(e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5 + e.amount_itemx6)
WHEN :month = '07' THEN Sum(e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5 + e.amount_itemx6 + e.amount_itemx7)
WHEN :month = '08' THEN Sum(e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5 + e.amount_itemx6 + e.amount_itemx7 + e.amount_itemx8)
WHEN :month = '09' THEN Sum(e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5 + e.amount_itemx6 + e.amount_itemx7 + e.amount_itemx8 + e.amount_itemx9)
WHEN :month = '10' THEN Sum(e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5 + e.amount_itemx6 + e.amount_itemx7 + e.amount_itemx8 + e.amount_itemx9 + e.amount_itemx10)
WHEN :month = '11' THEN Sum(e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5 + e.amount_itemx6 + e.amount_itemx7 + e.amount_itemx8 + e.amount_itemx9 + e.amount_itemx10 + e.amount_itemx11)
WHEN :month = '12' THEN Sum(e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5 + e.amount_itemx6 + e.amount_itemx7 + e.amount_itemx8 + e.amount_itemx9 + e.amount_itemx10 + e.amount_itemx11 + e.amount_itemx12) END AS col8,
CASE WHEN :month = '01' THEN Sum(i.amount_itemx1)
WHEN :month = '02' THEN Sum(i.amount_itemx1 + i.amount_itemx2)
WHEN :month = '03' THEN Sum(i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3)
WHEN :month = '04' THEN Sum(i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4)
WHEN :month = '05' THEN Sum(i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5)
WHEN :month = '06' THEN Sum(i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5 + i.amount_itemx6)
WHEN :month = '07' THEN Sum(i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5 + i.amount_itemx6 + i.amount_itemx7)
WHEN :month = '08' THEN Sum(i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5 + i.amount_itemx6 + i.amount_itemx7 + i.amount_itemx8)
WHEN :month = '09' THEN Sum(i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5 + i.amount_itemx6 + i.amount_itemx7 + i.amount_itemx8 + i.amount_itemx9)
WHEN :month = '10' THEN Sum(i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5 + i.amount_itemx6 + i.amount_itemx7 + i.amount_itemx8 + i.amount_itemx9 + i.amount_itemx10)
WHEN :month = '11' THEN Sum(i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5 + i.amount_itemx6 + i.amount_itemx7 + i.amount_itemx8 + i.amount_itemx9 + i.amount_itemx10 + i.amount_itemx11)
WHEN :month = '12' THEN Sum(e.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5 + i.amount_itemx6 + i.amount_itemx7 + i.amount_itemx8 + i.amount_itemx9 + i.amount_itemx10 + i.amount_itemx11 + i.amount_itemx12) END AS col9,
CASE WHEN :month = '01' THEN Sum(d.amount_itemx1)
WHEN :month = '02' THEN Sum(d.amount_itemx1 + d.amount_itemx2)
WHEN :month = '03' THEN Sum(d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3)
WHEN :month = '04' THEN Sum(d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4)
WHEN :month = '05' THEN Sum(d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5)
WHEN :month = '06' THEN Sum(d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5 + d.amount_itemx6)
WHEN :month = '07' THEN Sum(d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5 + d.amount_itemx6 + d.amount_itemx7)
WHEN :month = '08' THEN Sum(d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5 + d.amount_itemx6 + d.amount_itemx7 + d.amount_itemx8)
WHEN :month = '09' THEN Sum(d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5 + d.amount_itemx6 + d.amount_itemx7 + d.amount_itemx8 + d.amount_itemx9)
WHEN :month = '10' THEN Sum(d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5 + d.amount_itemx6 + d.amount_itemx7 + d.amount_itemx8 + d.amount_itemx9 + d.amount_itemx10)
WHEN :month = '11' THEN Sum(d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5 + d.amount_itemx6 + d.amount_itemx7 + d.amount_itemx8 + d.amount_itemx9 + d.amount_itemx10 + d.amount_itemx11)
WHEN :month = '12' THEN Sum(d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5 + d.amount_itemx6 + d.amount_itemx7 + d.amount_itemx8 + d.amount_itemx9 + d.amount_itemx10 + d.amount_itemx11 + d.amount_itemx12) END AS col10,
CASE WHEN :month = '01' THEN Sum(e.amount_itemx1 - i.amount_itemx1 - d.amount_itemx1)
WHEN :month = '02' THEN Sum((e.amount_itemx1 + e.amount_itemx2) - (i.amount_itemx1 + i.amount_itemx2) - (d.amount_itemx1 + d.amount_itemx2))
WHEN :month = '03' THEN Sum((e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3) - (i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3) - (d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3))
WHEN :month = '04' THEN Sum((e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4) - (i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4) - (d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4))
WHEN :month = '05' THEN Sum((e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5) - (i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5) - (d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5))
WHEN :month = '06' THEN Sum((e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5 + e.amount_itemx6) - (i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5+ i.amount_itemx6) - (d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5 + d.amount_itemx6))
WHEN :month = '07' THEN Sum((e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5 + e.amount_itemx6 + e.amount_itemx7) - (i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5+ i.amount_itemx6 + i.amount_itemx7) - (d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5 + d.amount_itemx6 + d.amount_itemx7))
WHEN :month = '08' THEN Sum((e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5 + e.amount_itemx6 + e.amount_itemx7 + e.amount_itemx8) - (i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5 + i.amount_itemx6 + i.amount_itemx7 + i.amount_itemx8) - (d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5 + d.amount_itemx6 + d.amount_itemx7 + d.amount_itemx8))
WHEN :month = '09' THEN Sum((e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5 + e.amount_itemx6 + e.amount_itemx7 + e.amount_itemx8 + e.amount_itemx9) - (i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5 + i.amount_itemx6 + i.amount_itemx7 + i.amount_itemx8 + i.amount_itemx9) - (d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5 + d.amount_itemx6 + d.amount_itemx7 + d.amount_itemx8 + d.amount_itemx9))
WHEN :month = '10' THEN Sum((e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5 + e.amount_itemx6 + e.amount_itemx7 + e.amount_itemx8 + e.amount_itemx9 + e.amount_itemx10) - (i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5 + i.amount_itemx6 + i.amount_itemx7 + i.amount_itemx8 + i.amount_itemx9 + i.amount_itemx10) - (d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5 + d.amount_itemx6 + d.amount_itemx7 + d.amount_itemx8 + d.amount_itemx9 + d.amount_itemx10))
WHEN :month = '11' THEN Sum((e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5 + e.amount_itemx6 + e.amount_itemx7 + e.amount_itemx8 + e.amount_itemx9 + e.amount_itemx10 + e.amount_itemx11) - (i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5 + i.amount_itemx6 + i.amount_itemx7 + i.amount_itemx8 + i.amount_itemx9 + i.amount_itemx10 + i.amount_itemx11) - (d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5 + d.amount_itemx6 + d.amount_itemx7 + d.amount_itemx8 + d.amount_itemx9 + d.amount_itemx10 + d.amount_itemx11))
WHEN :month = '12' THEN Sum((e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5 + e.amount_itemx6 + e.amount_itemx7 + e.amount_itemx8 + e.amount_itemx9 + e.amount_itemx10 + e.amount_itemx11 + e.amount_itemx12) - (i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5 + i.amount_itemx6 + i.amount_itemx7 + i.amount_itemx8 + i.amount_itemx9 + i.amount_itemx10 + i.amount_itemx11 + i.amount_itemx12) - (d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5 + d.amount_itemx6 + d.amount_itemx7 + d.amount_itemx8 + d.amount_itemx9 + d.amount_itemx10 + d.amount_itemx11 + d.amount_itemx12)) END AS col11,
Sum((e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5 + e.amount_itemx6 + e.amount_itemx7 + e.amount_itemx8 + e.amount_itemx9 + e.amount_itemx10 + e.amount_itemx11 + e.amount_itemx12)) AS col12,
Sum((i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5 + i.amount_itemx6 + i.amount_itemx7 + i.amount_itemx8 + i.amount_itemx9 + i.amount_itemx10 + i.amount_itemx11 + i.amount_itemx12)) AS col13,
Sum((d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5 + d.amount_itemx6 + d.amount_itemx7 + d.amount_itemx8 + d.amount_itemx9 + d.amount_itemx10 + d.amount_itemx11 + d.amount_itemx12)) AS col14,
Sum((e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5 + e.amount_itemx6 + e.amount_itemx7 + e.amount_itemx8 + e.amount_itemx9 + e.amount_itemx10 + e.amount_itemx11 + e.amount_itemx12) -
(i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5 + i.amount_itemx6 + i.amount_itemx7 + i.amount_itemx8 + i.amount_itemx9 + i.amount_itemx10 + i.amount_itemx11 + i.amount_itemx12) -
(d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5 + d.amount_itemx6 + d.amount_itemx7 + d.amount_itemx8 + d.amount_itemx9 + d.amount_itemx10 + d.amount_itemx11 + d.amount_itemx12)) AS col15
FROM table1 a
left OUTER JOIN table2 b
ON a.dstrct_code = b.dstrct_code
AND a.acct_segment1 = b.cost_ctre_seg
AND b.segment_level = '01'
left OUTER JOIN table2 c
ON a.dstrct_code = c.dstrct_code
AND a.acct_segment2 = c.cost_ctre_seg
AND c.segment_level = '02'
left OUTER JOIN table3 d
ON a.dstrct_code = d.dstrct_code
AND a.account_code = d.account_code
--AND d.currency_ind = '&Moneda_(L/D)'
AND trim(d.currency) = :currency
AND d.posting_type = '00'
AND d.ccyy_ind = :year
left OUTER JOIN table4 e
ON a.dstrct_code = e.dstrct_code
AND a.account_code = e.account_code
AND e.posting_type = '00'
AND e.ccyy_ind = :year
--AND e.budget_code = :budget
left OUTER JOIN table5 h
ON a.dstrct_code = h.dstrct_code
AND a.acct_segment3 = h.exp_element
left outer join (SELECT dstrct_code,
currency_ind,
currency,
account_code,
Sum(CASE WHEN substr(full_acct_per,1,4) < :year or (SubStr(full_acct_per,1,4) = :year AND SubStr(full_acct_per,5,2) = '01' )
THEN commit_value ELSE 0 END) amount_itemx1,
Sum(CASE WHEN SubStr(full_acct_per,1,4) =:year AND SubStr(full_acct_per,5,2) = '02'
THEN commit_value ELSE 0 END) amount_itemx2,
Sum(CASE WHEN SubStr(full_acct_per,1,4) =:year AND SubStr(full_acct_per,5,2) = '03'
THEN commit_value ELSE 0 END) amount_itemx3,
Sum(CASE WHEN SubStr(full_acct_per,1,4) =:year AND SubStr(full_acct_per,5,2) = '04'
THEN commit_value ELSE 0 END) amount_itemx4,
Sum(CASE WHEN SubStr(full_acct_per,1,4) =:year AND SubStr(full_acct_per,5,2) = '05'
THEN commit_value ELSE 0 END) amount_itemx5,
Sum(CASE WHEN SubStr(full_acct_per,1,4) =:year AND SubStr(full_acct_per,5,2) = '06'
THEN commit_value ELSE 0 END) amount_itemx6,
Sum(CASE WHEN SubStr(full_acct_per,1,4) = :year AND SubStr(full_acct_per,5,2) = '07'
THEN commit_value ELSE 0 END) amount_itemx7,
Sum(CASE WHEN SubStr(full_acct_per,1,4) =:year AND SubStr(full_acct_per,5,2) = '08'
THEN commit_value ELSE 0 END) amount_itemx8,
Sum(CASE WHEN SubStr(full_acct_per,1,4) =:year AND SubStr(full_acct_per,5,2) = '09'
THEN commit_value ELSE 0 END) amount_itemx9,
Sum(CASE WHEN SubStr(full_acct_per,1,4) =:year AND SubStr(full_acct_per,5,2) = '10'
THEN commit_value ELSE 0 END) amount_itemx10,
Sum(CASE WHEN SubStr(full_acct_per,1,4) =:year AND SubStr(full_acct_per,5,2) = '11'
THEN commit_value ELSE 0 END) amount_itemx11,
Sum(CASE WHEN SubStr(full_acct_per,1,4) =:year AND SubStr(full_acct_per,5,2) = '12'
THEN commit_value ELSE 0 END) amount_itemx12
FROM table6
WHERE dstrct_code = :district
AND SubStr(full_acct_per,1,4) <= :year
--AND currency_ind = '&Moneda_(L/D)'
AND trim(currency) = :currency
GROUP BY dstrct_code,
currency_ind,
currency,
account_code ) i
ON a.dstrct_code = i.dstrct_code
AND a.account_code = i.account_code
WHERE a.dstrct_code = :district
AND a.account_ind = '2'
GROUP BY Trim(a.acct_segment1)||' - '||trim(b.cctre_seg_name),
Trim(a.acct_segment2)||' - '||trim(c.cctre_seg_name),
Trim(a.acct_segment3)||' - '||Trim(h.exp_ele_desc)
HAVING Sum(d.amount_itemx1 + d.amount_itemx2 + d.amount_itemx3 + d.amount_itemx4 + d.amount_itemx5 + d.amount_itemx6 + d.amount_itemx7 + d.amount_itemx8 + d.amount_itemx9 + d.amount_itemx10 + d.amount_itemx11 + d.amount_itemx12) <> 0
OR Sum(e.amount_itemx1 + e.amount_itemx2 + e.amount_itemx3 + e.amount_itemx4 + e.amount_itemx5 + e.amount_itemx6 + e.amount_itemx7 + e.amount_itemx8 + e.amount_itemx9 + e.amount_itemx10 + e.amount_itemx11 + e.amount_itemx12) <> 0
OR Sum(i.amount_itemx1 + i.amount_itemx2 + i.amount_itemx3 + i.amount_itemx4 + i.amount_itemx5 + i.amount_itemx6 + i.amount_itemx7 + i.amount_itemx8 + i.amount_itemx9 + i.amount_itemx10 + i.amount_itemx11 + i.amount_itemx12) <> 0
ORDER BY Trim(a.acct_segment1)||' - '||trim(b.cctre_seg_name),
Trim(a.acct_segment2)||' - '||trim(c.cctre_seg_name),
Trim(a.acct_segment3)||' - '||Trim(h.exp_ele_desc)
EDIT: добавлены запросы и сообщения об ошибках.
Буду признателен за любую помощь.