Advertisement
Guest User

Untitled

a guest
Nov 13th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT JSONB_BUILD_OBJECT('product_id', "ct"."product_id", 'priorities', JSON_OBJECT_AGG("ct"."node_id", "ct"."priority")) AS "row"
  2. FROM (SELECT "t"."product_id" AS "product_id", "t"."node_id" AS "node_id", MAX("t"."priority") AS "priority"
  3.       FROM "product_priorities" AS "t"
  4.       INNER JOIN "node_to_product_enrg" AS "ntp"
  5.       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")
  6. 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