Table column vales to JSON object keys?

From: Wells Oliver <wells(dot)oliver(at)gmail(dot)com>
To: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Table column vales to JSON object keys?
Date: 2021-02-11 20:06:01
Message-ID: CAOC+FBU_ChUfOhVC9LJFOFwzQYH2=ZEBpY_cbNTL8zhexJvQow@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Trying to go from a table like:

g | e | angle | path
----+---+--------+----------------------
g1 | e1 | a1 | http://foo.com/a.mp4
g1 | e1 | a2 | http://foo.com/b.mp4
g1 | e1 | a3 | http://foo.com/c.mp4

To a table like this, with a column value per angle as a key.

g | e | obj
----+---+---------------------------------------------------------------------------------------------
g1 | e1 | {"a1": "http://foo.com/a.mp4", "a2": "http://foo.com/b.mp4",
"a3": "http://foo.com/c.mp4"}

Can't quite get there.

--
Wells Oliver
wells(dot)oliver(at)gmail(dot)com <wellsoliver(at)gmail(dot)com>

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message David G. Johnston 2021-02-11 20:13:02 Re: Table column vales to JSON object keys?
Previous Message Peter Eisentraut 2021-02-11 19:44:35 Re: pglogical with bytea values