CREATE TABLE city(
country character varying(64),
city character varying(64)
);
INSERT INTO city VALUES
('中国','台北'),
('中国','香港'),
('中国','上海'),
('日本','东京'),
('日本','大阪');
select country,string_agg(city,';' order by city desc) from city group by country
select country,array_agg(city) from city group by country
create table test_array(id int4[]);
INSERT INTO test_array(id) values(array[1,2,4]),(array[4,5,6]);
select array_agg(id) from test_array;
select array_length(id,1),id from test_array --显示一维度长度
select array_to_string(id,’ ‘) from test_array
select array_to_string(array_agg(id),’|') from test_array