How can i make two SELECT's into two json arrays from the same table?
╔════╦══════════════╦
║ id ║ users ║
╠════╬══════════════╬
║ 1 ║ Jeff Atwood ║
║ 2 ║ Geoff Dalgas ║
║ 3 ║ Jarrod Dixon ║
║ 4 ║ Joel Spolsky ║
╚════╩══════════════╩
How to combine this two selects in one query?
First select example
SELECT JSON_AGG(arr1) as arr1
FROM (
SELECT *
FROM users
WHERE id>1
) arr1
Second select example
SELECT JSON_AGG(arr2) as arr2
FROM (
SELECT *
FROM users
WHERE id<2
) arr2
Exprected:
[arr1: [{id:1}, {id:2}], arr2: [{id:1}, {id:2}]]
SELECT json_agg(*) AS arr1, json_agg(*) AS arr2 FROM users?