skip to Main Content

Postgresql group by and jsons just in one array

SQL Query like this below select json_build_array( json_build_object( 'entegrator_name', e2."name", 'provider_name', p."name", 'table1_count', count(t1.id) ) ) FROM table1 AS t1 JOIN entegrators AS e2 ON e.entegrator_id = e2.id JOIN providers AS p ON e.provider_id = p.id GROUP BY e2."name", p."name"…

VIEW QUESTION

How to rewrite a query without a subquery – Postgresql

I have this query: select qt.id as id, ev.id as event_id, res.allocation_date as date from quota qt left join result res on qt.id=res.quota_fk and (res.allocation_date=(select max(res2.allocation_date) from result res2 where res2.quota_fk=qt.id)) left join event ev on qt.id=ev.quota_fk this query correctly…

VIEW QUESTION
Back To Top
Search