UPDATE fact_orders1
SET m_order_created = (CASE WHEN fact_orders1.order_number = so.order_num THEN 1 ELSE 0 END)
WHERE order_number in (
SELECT so.order_num
FROM s_order so
JOIN s_order_item soi ON so.ROW_ID = soi.ORDER_ID
JOIN s_product sp ON soi.PROD_ID = sp.ROW_ID
JOIN s_order_type sot ON so.ORDER_TYPE_ID = sot.ROW_ID
JOIN s_order_x sox ON so.ROW_ID=sox.PAR_ROW_ID
WHERE (SUBSTR(LTRIM(sp.NAME), 1,3) IN ('VIP','BIZ')
OR sp.NAME IN ('HSBB Business 10 Mbps','HSBB Business 20 Mbps','HSBB Residential 10 Mbps','HSBB Residential 20 Mbps'))
AND sot.NAME = 'New Install' AND sp.PROD_CD = 'Promotion' AND sox.ATTRIB_11 = 'Y'
)
错误
====
FAILED:SemanticException [错误10004]:行1:82无效的表别名或列引用'所以' :(可能的列名是:order_number,created,last_upd,m_order_created)
如何解决这个问题?
答案 0 :(得分:0)
您无法在外部查询中引用子查询中的表,错误位于第二行:
CASE WHEN fact_orders1.order_number = so.order_num THEN 1 ELSE 0 END
so
限定符将不会被评估,您需要加入fact_orders1
和order_num
才能匹配order_number
和order_num
。