Re: [GENERAL] Issue with json_agg() and ordering

2017-09-01 Thread Bob Jones
>> >> 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,

[GENERAL] Issue with json_agg() and ordering

2017-09-01 Thread Bob Jones
Hi, Could anyone give me a few pointers as to how I might resolve the following : select json_agg(my_table) from (my_table) where foo='test' and bar='f' order by last_name asc, first_name asc; ERROR: column "my_table.last_name" must appear in the GROUP BY clause or be used in an aggregate