我有像
这样的表格ID AMT TYPE IAMT
----|-------|-------|------------
2Z7 | 720 | GS,NG | 54.00,21.11
2ZL | 721 | GS,NG | 45.23,11.20
2ZH | 727 | GS,NG | 62.34,25.45
2Z3 | 217 | GS,NG | 61.23,23.41
我尝试将逗号分隔值转换为带有查询
的行select ID,
AMT,
regexp_split_to_table(TYPE,',') as TYPE,
regexp_split_to_table(IAMT,',') as IAMT
from PAID
然后我得到了结果
ID AMT TYPE IAMT
--------|-------|-------|------------
2Z7 | 720 | GS | 54.00
2Z7 | 720 | NG | 21.11
2ZL | 721 | GS | 45.23
2ZL | 721 | NG | 11.20
2ZH | 727 | GS | 62.34
2ZH | 727 | NG | 25.45
2Z3 | 217 | GS | 61.23
2Z3 | 217 | NG | 23.41
但我想要这样的结果
ID AMT TYPE IAMT
--------|-------|-------|------------
2Z7 | 720 | GS | 54.00
| | NG | 21.11
2ZL | 721 | GS | 45.23
| | NG | 11.20
2ZH | 727 | GS | 62.34
| | NG | 25.45
2Z3 | 217 | GS | 61.23
| | NG | 23.41
我尝试了GROUP BY,但它没有用。 有没有办法得到像我想要的结果。