Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT JSONB_BUILD_OBJECT('product_id', "ct"."product_id", 'priorities', JSON_OBJECT_AGG("ct"."node_id", "ct"."priority")) AS "row"
- FROM (SELECT "t"."product_id" AS "product_id", "t"."node_id" AS "node_id", MAX("t"."priority") AS "priority"
- FROM "product_priorities" AS "t"
- INNER JOIN "node_to_product_enrg" AS "ntp"
- INNER JOIN UNNEST((21)) AS "node_ids" ON ("ntp"."node_id" = "node_ids") ON ("t"."product_id" = "node_to_product_enrg" AS "ntp" INNER JOIN UNNEST((21)) AS "node_ids" ON ("ntp"."node_id" = "node_ids")."product_id")
- WHERE "t"."country_id" = 'RU' AND "t"."business_id" = 'ENRG' GROUP BY "t"."product_id", "t"."node_id") AS "ct" GROUP BY "ct"."product_id"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement