Friday, December 7, 2012

PostgreSQL – Convert rows to string

SELECT array_to_string(
    array(
        SELECT name
        FROM pg_settings
        WHERE setting = 'off' AND context = 'postmaster'
    ), ',');

SELECT setting, array_to_string(array_agg(name), ',')
FROM pg_settings
WHERE setting IN ('on', 'off')
GROUP BY setting;

No comments:

Post a Comment