我必须对字段中每一行的可能值进行描述 我不必展示BASE类。
SELECT A.COD_PUNTO,
wm_concat(SUBSTR(C.DESCARDPRFCFR, 22, 10)) AS LIST
FROM FR_VALID_PROF A
INNER JOIN PUN B
ON A.COD_PUNTO = B.COD_PUNTO
INNER JOIN DANAFR C
ON A.CODPRF = C.CARDPRFCFR
GROUP BY A.COD_PUNTO
我的结果是:
COD_PUNTO | LIST
---------------------
0 | BASE, SUNDAY
1 | BASE, SUNDAY, ORANGE, ORANGE
2 | BASE, BASE, SUNDAY, SUNDAY, ORANGE, ORANGE, ORANGE
但是我想要
COD_PUNTO | LIST
---------------------
0 | SUNDAY
1 | SUNDAY, ORANGE
2 | SUNDAY, ORANGE
我不能使用listagg,因为我使用过wm_concat。
答案 0 :(得分:0)
使用子查询和DISTINCT子句:
SELECT COD_PUNTO, wm_concat(SUBSTR(DESCARDPRFCFR, 22, 10)) AS LIST
FROM (
SELECT DISTINCT A.COD_PUNTO, C.DESCARDPRFCFR
FROM FR_VALID_PROF A
INNER JOIN PUN B
ON A.COD_PUNTO = B.COD_PUNTO
INNER JOIN DANAFR C
ON A.CODPRF = C.CARDPRFCFR
)
WHERE DESCARDPRFCFR <> 'BASE'
GROUP BY COD_PUNTO