I need to un-parse JSON with lateral flatten. But I would like to have 2 values - one for club and one for free delivery, for club I am ok, but I can not get also free delivery This is code I have
select LPAD(PURCHASE_ID,10, '0')as PURCHASE_ID, DELIVERY_ID, PARTNER_ID,HAS_LABEL_FDEL, f3.value:commonLabels[0]::varchar as CLUB --,ORDER_ID as ue
from (select distinct PURCHASE_ID, DELIVERY_ID, PARTNER_ID,HAS_LABEL_FDEL, PARSE_JSON(PR_TRANSPORT) as PR_TRANSPORT from "DWHM_MALLGROUP"."SRC_ORACLEIWP"."PURCHASE_ANALYSIS_RULES"
) as PAR,
lateral flatten(input => PAR.PR_TRANSPORT) f3
where PR_TRANSPORT is not null
and f3.value:type='CLUB' ---????or f3.value:type='FREE_DELIVERY'
and here is parse JSON looks like this for free delivery, which i would like to have :
[{"ruleId":244419,"type":"FREE_DELIVERY"},{"ruleId":9942304,"type":"FREE_DELIVERY"}] This is how it looks for club : [{"commonLabels":["CZ_B2B_CLUB"],"ruleId":20228738,"type":"CLUB"}]
So one field for CLUBS, one for Free delivery