我有一个直通查询,就像我期望的那样运行。但是,当我在make table查询(Access)中使用它时,我收到一条错误消息,指出“指定的字段passThru3.vaulLocation可以引用SQL语句的FROM子句中列出的多个表”。
vaultlocation字段由来自几个不同表的字段组成。
下表显示了生成表查询和直通查询。如何克服这个问题的任何建议将不胜感激。谢谢你的帮助......
制作表格查询:
SELECT PassThru3.ItemID, PassThru3.unit, PassThru3.vin, PassThru3.modlYr, PassThru3.make, PassThru3.model, PassThru3.actDate, PassThru3.actUser, PassThru3.groupNbr_branchNbr, PassThru3.vaultLocatiion, PassThru3.br_iorg_id INTO TitleInfo FROM PassThru3;
PassThrough查询:
SELECT
tm.title_id as itemID,
v.lgcy_unit_nbr as unit,
v.vin,
v.modl_yr_nbr as modlYr,
v.make_cde as make,
v.make_modl_dsc as model,
ta.create_timestamp as actDate,
ta.user_id as actUser,
--ta.notes as actNotes,
lrd.lgcy_iorg_id as groupNbr_branchNbr,
CASE
WHEN vs.vault_req = 0 THEN 'No Vault'
WHEN vs.vault_type_id = 2 AND vs.vault_req = 1 THEN (lrd.lgcy_iorg_id || '-' || ti.seq_nbr)
WHEN vs.vault_type_id = 1 AND vs.vault_req = 1 THEN (tc.cabinet_nbr ||'-' || td.drawer_nbr ||'-' || tf.folder_nbr ||'-' || ts.seq_nbr)
END as vaultLocation,
tm.br_iorg_id
FROM VEH_MGMT_TMS.TITLE_MASTER tm
join LRD.LRD_IORG lrd on tm.br_iorg_id = lrd.iorg_id
JOIN VEH_MGMT_TMS.VEH v ON tm.veh_id = v.veh_id
LEFT OUTER JOIN VEH_MGMT_TMS.VAULT_SETTINGS vs on tm.br_iorg_id = vs.br_iorg_id and vs.item_type_id = 1
LEFT OUTER JOIN VEH_MGMT_TMS.TITLE_INCREMENTAL ti on tm.title_id = ti.title_id
LEFT OUTER JOIN VEH_MGMT_TMS.TITLE_SEQ ts on tm.title_id = ts.title_id
LEFT OUTER JOIN VEH_MGMT_TMS.TITLE_FOLDER tf on ts.folder_id = tf.folder_id
LEFT OUTER JOIN VEH_MGMT_TMS.TITLE_DRAWER td on tf.drawer_id = td.drawer_id
LEFT OUTER JOIN VEH_MGMT_TMS.TITLE_CABINET tc on td.cabinet_id = tc.cabinet_id
JOIN VEH_MGMT_TMS.TITLE_ACTIVITY ta ON tm.title_id = ta.title_id AND ta.title_act_id =
(select max(title_act_id) from VEH_MGMT_TMS.TITLE_ACTIVITY where title_id = tm.title_id and act_type_id = 1)
WHERE tm.transit_flag = 0
and ta.create_timestamp >= (current_date - INTERVAL '3' MONTH)