create table tab (id int, name char(16)); insert into tab values (1, 'abc'); insert into tab values (2, 'def'); select string_agg(to_char(id,'999'), ','), string_agg(name, ',') from tab; postgres runtime function call trace, click each function to explore PostgresMain exec_simple_query ... PortalRun ... advance_aggregates ... int4_to_char