1: select json_agg(rw) as data,
max(cnt) as count
from (
select to_jsonb(users.*) as rw,
count(*) over () as cnt
from admin.users
inner join admin.access_group on access_group.id=users.access_group
limit 25 offset 0 ) q
2: SELECT
(SELECT COUNT(*)
FROM admin.users
WHERE 1=1
) as count,
(SELECT json_agg(t) FROM (
SELECT *
FROM admin.users u
inner join admin.access_group on access_group.id=u.access_group
where 1=1
ORDER BY u.id
OFFSET 0
LIMIT 25
) AS t) AS data
Второй вроде требует меньшэ запоминания промежуточных смыслов и у него меньшэ использования неочевидных эффектов.
Обсуждают сегодня