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
LeetCode 178
Ecommerce Website Analysis by SQL
Mandelbrot
pgsql trigger 01 - Ovocie
conditionally add “another row” in SQL Server?
Assignment 1(SET A)
SQL social network practice by Han Wang 20200720 - 2
Cross Tab With Totals
JsonB Query
Food Delivery Website SQL Analysis