>> >> I guess that the order by should be in the aggregation. >> >> SELECT json_agg(a.* ORDER BY a.last_name, a.last_year DESC) >> FROM my_table a; > > yes. however, you would say, json_agg(a... not 'a.*'). The .* > notation only works in certain contexts, and is transformed at parse > time to, a.col1, a.col2, a.col3... which would not work inside an > aggregation function which can only handle a single column or record. > > merlin Awesome ! Thanks Charles for the answer, and Merlin for the tweaking/additional insight. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general