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
stackoverflow example for 47702144
menu sample
E-Commerce SQL Analysis by Ran Li
Final 1
Limit & union
Movie Rating SQL Analysis Conducted by Miranda Zhao
Leetcode 569. Median Employee Salary
Product Sales Analysis I - III
Assignment 1(SET A)
tic tac toe