Home > database >  Oracle query multistage parent merged, when children use commas
Oracle query multistage parent merged, when children use commas

Time:09-24


Such as query of China's provinces and cities; The desired result is
The city of A province B, C, D,
1 province 2, 3,,,,,,,,, etc. Please answer

CodePudding user response:

Listagg (city, ', ') within group (order by city)
Group by province

CodePudding user response:

 
SELECT province, listagg (CAST (city) AS VARCHAR2 (200)), ', ') within group (order by 1) AS the city 2 group by province

CodePudding user response:

Select province, wm_concat (city) from t group by province

CodePudding user response:

Select province, wm_concat (city),

Group by province
  • Related