Using unnest to build pivot table
Example code:
SELECT 'SELECT * FROM unnest(
''{sl_no, username, designation, salary}''::text[]
, ' || string_agg(quote_literal(ARRAY[sl_no::text, username::text, designation::text, salary::text])
|| '::text[]', E'\n, ')
|| E') \n AS t(col,' || string_agg('row' || sl_no, ',') || ')' AS sql
FROM tbl;
On this page of the site you can watch the video online Dynamic column in postgresql with a duration of hours minute second in good quality, which was uploaded by the user Trâm Trần 15 March 2020, share the link with friends and acquaintances, this video has already been watched 1,436 times on youtube and it was liked by 8 viewers. Enjoy your viewing!