现在有两个表,表a中
DOC | FID |
1 | a,b,c |
2 | a,c,d |
表b中
ID | KEY |
a | A |
b | B |
c | C |
d | D |
怎么联合查询出
DOC | FID | KEY |
1 | a,b,c | A,B,C |
2 | a,c,d | A,C,D |
解决方案:
SELECT
A .DOC,
A .fid
(
SELECT
listagg (b.key, ',') WITHIN GROUP (ORDER BY b.id)
FROM
b b
WHERE
INSTR (
',' || A .fid || ',',
',' || b.id || ','
) > 0
) fdKey
FROM
a A
WHERE whereblock