Of course you can have a LIKE in a join condition.
You just wrote the joins in wrong order. In ON you can/must use columns from any of the previously defined tables.
Rearrange it like this:
FROM
ntl_prd_secvm.CUST_ACCT_LINE_V CALT
INNER JOIN
ntl_prd_secvm.equip_sum_fact_v esf
ON ESF.ESN_CHANGE_REAS_CD = CALT.ESN_CHANGE_REAS_CD
AND ESF.SOR_ID = CALT.SOR_ID
AND ESF.MTN = CALT.MTN
AND ESF.CUST_LINE_SEQ_ID = CALT.CUST_LINE_SEQ_ID
LEFT OUTER JOIN
ntl_prd_secvm.POS_TRANS_V POS
ON esf.sor_id =pos.sor_id
AND esf.cust_id =pos.cust_id
AND esf.cust_line_seq_id= pos.cust_line_seq_id
AND esf.invc_num=pos.invc_num
INNER JOIN
OUTLET_V O
ON
POS.SOR_ID = O.SOR_ID
AND POS.SLS_OUTLET_ID = O.SLS_OUTLET_ID
AND
(
MASTER_AGENT_ID LIKE '%APPLE%'
OR STORE_TYPE_IND = 'S'
)This query will change the Left ton an Inner Join, you should check if OUTLET_V must be outer joined, too.
Dieter
↧