报错说mismatched input 'WITH' expecting
时间: 2023-07-05 13:35:54 浏览: 375
这个报错可能是因为WITH语句不支持在某些特定的SQL版本中使用。你可以尝试将WITH语句改写成子查询的形式,例如:
```
SELECT DISTINCT A.calling_imsi AS IMSI, coalesce(B.ANTIGUA,C.ANTIGUA) AS GJ, coalesce(B.APUA,C.APUA) AS YYS
FROM (
SELECT calling_imsi, substr(calling_imsi,1,6) AS calling_imsi_6, substr(calling_imsi,1,5) AS calling_imsi_5, substr(calling_imsi,1,4) AS calling_imsi_4
FROM spark_odc_dwd.D_ENS_GBSSAP_CC
WHERE p_hour='#{time yyyyMMddHH}'
) A
LEFT JOIN (
SELECT SUBSTR(regexp_replace(IMSI,'[^0-9]+',''),1,6) AS IMSI_6, SUBSTR(regexp_replace(IMSI,'[^0-9]+',''),1,5) AS IMSI_5, ANTIGUA, APUA
FROM spark_odc_data.A_DM_CO_BA_VR_OPT_IMSI
) B ON A.calling_imsi_6=B.IMSI_6
LEFT JOIN (
SELECT SUBSTR(regexp_replace(IMSI,'[^0-9]+',''),1,6) AS IMSI_6, SUBSTR(regexp_replace(IMSI,'[^0-9]+',''),1,5) AS IMSI_5, ANTIGUA, APUA
FROM spark_odc_data.A_DM_CO_BA_VR_OPT_IMSI
) C ON A.calling_imsi_5=C.IMSI_5;
```
这样就可以避免使用WITH语句了。
阅读全文