Instructions for using Oracle function Listagg
At work, customers often come up with the requirement that they want to enumerate the dates one by one in a summary merge.
, the original data is this:
Customers want to be able to achieve such a summary consolidation:
So I usually use the Listagg function, but a lot of the online system is a comprehensive introduction Listagg the use of this function, looks very laborious. I'm here to explain briefly.
The statement that implements the requirement is this:
Select Name,
Listagg (Ddate, '/') within group (order by name) as Ddate
From AA
Group BY name
Things to note are as follows:
1. A scoring group is required, i.e. group by is required.
2. The first parameter of the Listagg function is the field that needs to be enumerated, that is, ddate; the second argument is the delimiter between the enumeration values, and it also needs to be sorted and grouped within group (order by name)
Instructions for using Oracle function Listagg