LISTAGG
Syntax
LISTAGG
(
expression IN TEXT
)
RETURNS text;
LISTAGG
(
expression IN TEXT,
delimite IN TEXT
)
RETURNS text;Overview
Parameters
Parameter
Description
Example
Last updated
LISTAGG
(
expression IN TEXT
)
RETURNS text;
LISTAGG
(
expression IN TEXT,
delimite IN TEXT
)
RETURNS text;Last updated
# test table
create table employees ( first_name varchar, last_name varchar );
INSERT INTO employees (first_name, last_name) VALUES
('John', 'Doe'),
('Jane', 'Smith'),
('Michael', 'Johnson'),
('Emily', 'Davis'),
('David', 'Wilson'),
('Sarah', 'Brown'),
('James', 'Taylor'),
('Jessica', 'Martinez'),
('Daniel', 'Anderson'),
('Laura', 'Thomas');
# test 1
select oracle.listagg(last_name, ',') from employees ;
listagg
----------------------------------------------------------------------
Doe,Smith,Johnson,Davis,Wilson,Brown,Taylor,Martinez,Anderson,Thomas
(1 row)
# test 2
select oracle.listagg(last_name) from employees ;
listagg
-------------------------------------------------------------
DoeSmithJohnsonDavisWilsonBrownTaylorMartinezAndersonThomas
(1 row)