How to fetch the string from the column of table in postgresql?
SELECT 'userid=' || Userid::text
     , 'dist_code(' || string_agg(District_code::text, ',') || ')'
FROM table
GROUP BY Userid
-- WHERE userid=1