我想执行此查询,但得到ORA-00904:“QM”。“MDL_MDL_ID”:无效的标识符。更令人困惑的是,主查询有两个子查询,它们只在where子句中有所不同。但是,第一个查询运行良好,但第二个查询出错。以下是查询。SQL相关子查询
select (
select make_description
from [email protected]
where makc_id = (
select makc_makc_id
from [email protected]
where to_char(mdc_id) = md.allocate_vehicle_colour_id
)
) as colour,
(
select make_description
from [email protected]
where makc_id = (
select makc_makc_id
from [email protected]
where mdl_mdl_id = qm.mdl_mdl_id
)
) as vehicle_colour
from schema1.web_order wo,
schema1.tot_order tot,
[email protected] sp,
[email protected] ea,
schema1.location_contact_detail lcd,
[email protected] 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)
我可以确保它确实有该列。 –
如果我只写**,请选择qm.mdl_mdl_id作为Vehicle_colour **,它工作正常。 –
'as vehicle_colour,'drop this comma – Serg