select *
FROM prd_raw_sf.sf_opportunity_dn A JOIN
prd_raw_sf.sf_opportunity_rw B
ON A.OPPORTUNITYID = B.SFDC_ID LEFT JOIN
prd_raw_sf.sf_si_accounts_mapping C
ON TRIM(UPPER(A.ACCOUNT_NAME)) = TRIM(UPPER(C.sfdc_account_name))
WHERE C.sfdc_account_name IS NULL
and C.Billing_Client in ('CL.00000:')
It returns the necessary results when I query till "WHERE C.sfdc_account_name IS NULL". However, if I add the last line... "and C.Billing_Client in ('CL.00000:')", it just returns 0 result. Please help!
I speculate that you intend:
SELECT *
FROM prd_raw_sf.sf_opportunity_dn od JOIN
prd_raw_sf.sf_opportunity_rw orw
ON od.OPPORTUNITYID = orw.SFDC_ID LEFT JOIN
prd_raw_sf.sf_si_accounts_mapping am
ON TRIM(UPPER(od.ACCOUNT_NAME)) = TRIM(UPPER(ord.sfdc_account_name)) AND
am.Billing_Client in ('CL.00000:')
WHERE am.sfdc_account_name IS NULL;
It is impossible for the account name to be NULL
after the LEFT JOIN
and for the Billing_Client
to be anything other than NULL
. That is because the account name is used as a JOIN
key, so NULL
does not match. The NULL
value indicates no match, so all other columns from the table are NULL
.
Note that I also fixed the table aliases so they are meaningful rather than arbitrary letters.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.