You can unpivot in a lateral join - but as mentionned by Dai in the comments, this requires casting all values to the same datatype. So:
select x.*
from mytable t
cross join lateral ( values
( 'Id', id::text ),
( 'Name', name ),
( 'Age', age::text)
) x(col, val)
'abc'but the others areintvalues. Anyway, the human-readable display of a resultset is a presentation layer concern, so you should implement transposition in your PHP/cshtml/report-generator tool instead.PIVOT/UNPIVOT- and Postgres hascrosstab(which isn't enabled by default) - but in both cases they only support tranformations of tables such that all output rows use the same output columns (name and type).