救助:ora-01427:单行子查询返回多个行 本帖最后由 jin2106 于 2012-11-03 19:19:55 编辑
要将dwu_bqf_item_day 中的lastyear_value 更新为bq_data_lastyear 表中的lastyearvalue值。
dwu_bqf_item_day (DATA_DATE,ITEM_CODE,CORP_CODE)等字段
bq_data_lastyear (DATA_DATE,ITEM_CODE,CORP_CODE)等字段
语句是以下这样写的:
Update dwu_bqf_item_day a
Set a.lastyear_value = (select b.lastyearvalue
from bq_data_lastyear b
where a.corp_code = b.corp_code
and a.item_code = b.item_code)
Where exists (select 1
from bq_data_lastyear b
where a.corp_code = b.corp_code
and a.item_code = b.item_code) ------最佳解决方案--------------------
加rownum=1就行,只要你确定返回的多行都是相同值 ------其他解决方案-------------------- Update dwu_bqf_item_day a
Set a.lastyear_value = (select b.lastyearvalue
from bq_data_lastyear b
where a.corp_code = b.corp_code
and a.item_code = b.item_code and rownum=1)
Where exists (select 1
from bq_data_lastyear b
where a.corp_code = b.cor