How to fetch the string from the column of table in postgresql? I have the following table

Userid  District_code
1        05
1        03
2        03
2        04
3        06


and want to get this output:

userid=1 dist_code(05,03)
SELECT 'userid=' || Userid::text
     , 'dist_code(' || string_agg(District_code::text, ',') || ')'
FROM table
GROUP BY Userid
-- WHERE userid=1