Diway wrote
> I could use something like this (not tested!)
> --
> select fk_item_header_id as id, json_agg(row(message_id, dt_created,
> lines, size, current_part, status, fk_item_cat_id)) as data from item
> group by fk_item_header_id;
> --
CREATE TYPE
http://www.postgresql.org/docs/9.3/interactive/sql-createtype.html
Since you have a known set of columns you define a custom type that matches
the structure and then:
SELECT fk_item_header_id, json_agg( ( message_id, dt_create, ...
)::custom_type ) FROM ...;
Not tested as I do not have a JSON capable release available at the moment.
But since the type information includes the column names the conversion to
JSON should keep those names intact.
David J.
--
View this message in context: http://postgresql.1045698.n5.nabble.com/json-and-aggregate-tp5776903p5776920.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.