PostgreSQL 9.3
menawarkan fungsi JSON rapi yang dapat digunakan untuk tugas-tugas tersebut tanpa mendefinisikan fungsi baru atau mengetahui sejumlah kolom.
SELECT id, (k).key as year, (k).value as value FROM
(SELECT j->>'id' as id, json_each_text(j) as k
FROM (
SELECT row_to_json(tbl) as j FROM tbl)
as q)
as r
WHERE (k).key <> 'id';
http://sqlfiddle.com/#!15/1714b/13