我有一个简单的问题
我在以下查询中创建了两个别名 - ' newpostcode'和' normalizedpostcode'
我想基于这些字段加入 - 有没有人知道如何基于别名而不是已建立的字段来连接两个表?
SELECT mme_1.dt, event_id, magnet.postcode, ukpostcode_lookup.postcode, lat, long,
REGEXP_REPLACE(magnet.postcode, '\\s+', '') as newpostcode,
REGEXP_REPLACE(ukpostcode_lookup.postcode, '\\s+', '') as normalizedpostcode
FROM mme_1
LEFT JOIN magnet ON mme_1.lkey = magnet.lkey
LEFT JOIN ukpostcode_lookup on newpostcode = normalizedpostcode
WHERE mme_1.dt="20170419" AND event_result="success" AND ((event_id="l_pdn_connect" AND apn_name LIKE "ims.%") OR (event_id="l_dedicated_bearer_activate"))
GROUP BY mme_1.dt, event_id, magnet.postcode, ukpostcode_lookup.postcode, lat, long
LIMIT 100;