这是SQL:
SELECT alloc.oa_id
FROM qdod.qtran_owner_allocation alloc
INNER JOIN
(SELECT h.oa_id, h.div_ord_no, h.process_queue_id, h.from_ba_no,
h.from_ba_suf, h.from_interest_type_cd, h.from_interest_type_cd, h.from_div_ord_grp,
h.transfer_percent, h2.original_net_amount, h2.new_net_amount
FROM qdod.qtran_fund_transfer_hist h
INNER JOIN
(SELECT DISTINCT h0.oa_id, h0.original_net_amount, h1.new_net_amount
FROM qdod.qtran_fund_transfer_hist h0
INNER JOIN
(SELECT h4.oa_id, SUM (h4.new_net_amount) AS new_net_amount
FROM qdod.qtran_fund_transfer_hist h4
GROUP BY h4.oa_id) h1
ON h0.oa_id = h1.oa_id
WHERE h0.original_net_amount <> h1.new_net_amount AND h0.oa_id >= 100000000) h2
ON h.oa_id = h2.oa_id) h3
ON alloc.oa_id = h3.oa_id;
每列都定义了表格。主内连接(在alloc表之后的连接)在单独运行时运行正常。任何想法为什么这不起作用?这是针对Oracle 10.2.0.4数据库执行的(我还尝试过针对11.2.0.1数据库的思考,如果它是一个Oracle错误,它将在11.2中解决,但它也失败了。)
答案 0 :(得分:5)
声明中重复的字段可能与它有关
h.from_interest_type_cd, h.from_interest_type_cd,
答案 1 :(得分:2)
您似乎选择了许多您不需要的列,因为您没有在任何地方使用它们。该查询可能简化为:
SELECT alloc.oa_id
FROM qdod.qtran_owner_allocation alloc
INNER JOIN
(SELECT h.oa_id
FROM qdod.qtran_fund_transfer_hist h
INNER JOIN
(SELECT DISTINCT h0.oa_id
FROM qdod.qtran_fund_transfer_hist h0
INNER JOIN
(SELECT h4.oa_id, SUM (h4.new_net_amount) AS new_net_amount
FROM qdod.qtran_fund_transfer_hist h4
GROUP BY h4.oa_id) h1
ON h0.oa_id = h1.oa_id
WHERE h0.original_net_amount <> h1.new_net_amount AND h0.oa_id >= 100000000) h2
ON h.oa_id = h2.oa_id) h3
ON alloc.oa_id = h3.oa_id;