After group by field, merge processing of other fields

I want to do a query myself, something like

select age,name from student group by age

 But obviously this doesn't work, because you have grouped the age, so how to deal with the name, generally take the maximum value max(name). The minimum value min(name), or if it is a number, you can also sum(name), but what I want to do is to combine all the different names, similar to this

18 Zhang San, Li Si

20 Wang Wu, Liu Liu

Combine the remaining fields so that I can see more clearly. After consulting the dba, I know that I can do this

select age ,listagg(name,',') within GROUP (order by name) name from student group by age

 In this way, the function I want is realized. I will take a note here, in case the dba leaves in the future, or if I leave and cannot find this information, I will also share it with you.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327043090&siteId=291194637
Recommended