我有一个选择查询,我想要
TRIM
一列,该列已经作为 MAX 函数。我尝试了下面的方法,但它不起作用。
SELECT MAX( id ) KEEP ( -- 102436
DENSE_RANK LAST
ORDER BY TENANCY_CHANGEDDATE NULLS FIRST,
RRH_CHANGEDDATE NULLS FIRST,
ID_OD_CHANGEDDATE NULLS FIRST
) AS id,
MAX( cmp ) KEEP (
DENSE_RANK LAST
ORDER BY TENANCY_CHANGEDDATE NULLS FIRST,
RRH_CHANGEDDATE NULLS FIRST,
ID_OD_CHANGEDDATE NULLS FIRST,
id
) AS cmp,
MAX(TRIM(SITE_NAME)) KEEP (
-- regex_replace( MAX( SITE_NAME ), '\W', '') KEEP (
DENSE_RANK LAST
ORDER BY SITE_NAME NULLS FIRST,
id
) AS SITE_NAME
FROM TBL_IPCOLO_BILLING_MST
GROUP BY sap_id;
看起来您正在尝试将 MAX 函数内的 TRIM 函数与 KEEP 子句一起使用
SELECT MAX(id) KEEP (DENSE_RANK LAST ORDER BY TENANCY_CHANGEDDATE NULLS FIRST, RRH_CHANGEDDATE NULLS FIRST, ID_OD_CHANGEDDATE NULLS FIRST) AS id,
MAX(cmp) KEEP (DENSE_RANK LAST ORDER BY TENANCY_CHANGEDDATE NULLS FIRST, RRH_CHANGEDDATE NULLS FIRST, ID_OD_CHANGEDDATE NULLS FIRST, id) AS cmp,
MAX(TRIM(SITE_NAME)) KEEP (DENSE_RANK LAST ORDER BY SITE_NAME NULLS FIRST, id) AS SITE_NAME
来自 TBL_IPCOLO_BILLING_MST 按 sap_id 分组;
确保在应用 TRIM 函数之前关闭 MAX 函数的括号。另外,请确保要应用 TRIM 函数的列是字符串数据类型