【发布时间】:2017-02-12 09:08:40
【问题描述】:
我正在尝试执行此查询,但收到 ORA-00904:"QM"."MDL_MDL_ID":invalid identifier。更让我困惑的是主查询有两个子查询,它们仅在 where 子句中有所不同。但是,第一个查询运行良好,但第二个查询出错。以下是查询。
select (
select make_description
from make_colours@dblink1
where makc_id = (
select makc_makc_id
from model_colours@dblink1
where to_char(mdc_id) = md.allocate_vehicle_colour_id
)
) as colour,
(
select make_description
from make_colours@dblink1
where makc_id = (
select makc_makc_id
from model_colours@dblink1
where mdl_mdl_id = qm.mdl_mdl_id
)
) as vehicle_colour
from schema1.web_order wo,
schema1.tot_order tot,
suppliers@dblink1 sp,
external_accounts@dblink1 ea,
schema1.location_contact_detail lcd,
quotation_models@dblink1 qm,
schema1.manage_delivery md
where wo.reference_id = tot.reference_id
and sp.ea_c_id = ea.c_id
and sp.ea_account_type = ea.account_type
and sp.ea_account_code = ea.account_code
and lcd.delivery_det_id = tot.delivery_detail_id
and sp.sup_id = tot.dealer_id
and wo.qmd_id = qm.qmd_id
and wo.reference_id = md.web_reference_id(+)
and supplier_category = 'dealer'
and wo.order_type = 'tot'
and trunc(wo.confirmdeliverydate - 3) = trunc(sysdate)
【问题讨论】:
-
我可以保证它确实有那一栏。
-
如果我只写 select qm.mdl_mdl_id as Vehicle_colour 它工作正常。
-
as vehicle_colour,去掉这个逗号 -
@Serg :抱歉,提问时打错字了。
标签: sql oracle correlated-subquery