Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Join elements by key with json fields
--PostgreSQL 9.6 --'\\' is a delimiter -- Join elements by key with json fields CREATE TABLE customer_json ( ID serial NOT NULL PRIMARY KEY, info json NOT NULL ); truncate table customer_json; INSERT INTO customer_json (info) VALUES ( '{ "customer": "John Doe"}' ); INSERT INTO customer_json (info) VALUES ( '{ "customer": "Peter Doe"}' ); INSERT INTO customer_json (info) VALUES ( '{ "customer": "Welsey Doe"}' ); select json_agg(info) from customer_json -- Result: -- [{ "customer": "John Doe"}, { "customer": "Peter Doe"}, { "customer": "Welsey Doe"}] -- -- Wanted: -- [{ "customer": ["John Doe", "Peter Doe", "Welsey Doe"]}]
run
|
edit
|
history
|
help
0
Comp
Ankit
Pedido_Insert_Delete
Christmas Tree Generator
Codigo_Completo
distinct on vs row_number
tic tac toe
E2
Pedido
Timestamps in PostgreSQL