"""Select all distinct values in a group of fields.""" SELECT_RPODUCT_PARTICIPANTS_INFO = """ WITH sme_products_participants as ( SELECT pp.upc, pp.PARTICIPANT_NAME, FROM FACTS.PROD.SME_LABELCOPY_PRODUCT_PARTICIPANT pp WHERE pp.ROLE = 'Primary' ), orchard_products_lebel_participants as ( select r.upc, lp.name as participant_name, lp.uuid as label_participant_uuid, r.release_id as product_id, p.vendor_id, -- ORCHLABELID p.subaccount_id, from ORCHARD_APP_REPORTING_V2.ART_RELATIONS_PROD_ART_RELATIONS.releases r inner join ORCHARD_APP_REPORTING_V2.ART_RELATIONS_PROD_ART_RELATIONS.project p on r.project_id = p.project_id join facts.prod.label_participant lp on lp.vendor_id = p.vendor_id and lp.subaccount_id = p.subaccount_id ) select orchard_pp.* from sme_products_participants sme_pp inner join orchard_products_lebel_participants orchard_pp on sme_pp.upc = orchard_pp.upc and sme_pp.participant_name = orchard_pp.participant_name -- to ignore leading zeros problem like 0000598797887 in sme tables where to_number(sme_pp.upc) in (:upcs) order by upc, participant_name ; """