rewrite all for greenplum 6 using temporary tables, process all code [code]
- User
rewrite all for greenplum 6 using temporary tables, process all code
SELECT list_id, listdate, mdm_id, short_name, sector_id, sector_name, cat_id, cat_name, slice_id, underlyingid, ticker, cik, sic, office, industry, country_code, country_name, is_clr, req_id, updatedt FROM (SELECT distinct t2.list_id,t2.LISTDATE,t2.mdm_id,t2.short_name,t2.SECTOR_ID,t2.sector_name, CASE WHEN t2.country_code=643 THEN (t2.ORG_CATEGORY_ECBD)::numeric ELSE t2.cat_id END cat_id, CASE WHEN t2.country_code=643 THEN t2.ORG_CATEGORY_NAME_ECBD ELSE t2.cat_name END cat_name, v_slice_id slice_id, null underlyingid, null ticker, null cik, null sic, null office, null industry, t2.country_code,t2.country_name,t2.is_clr,0 req_id,clock_timestamp() updatedt FROM schema.v_table_name t2 WHERE t2.list_id = v_list_id AND (t2.emt_status_id is null or t2.emt_status_id = 7) AND country_code != 840 union all SELECT list_id, listdate, mdm_id, short_name, sector_id, sector_name, cat_id, cat_name, slice_id, underlyingid, ticker, cik, sic, office, industry, country_code, country_name, is_clr, 0, clock_timestamp() FROM ( SELECT distinct t2.list_id,t2.LISTDATE,t2.mdm_id,t2.short_name,t2.SECTOR_ID,t2.sector_name, t2.cat_id, t2.cat_name, v_slice_id slice_id, t4.underlyingid, t5.ticker, t5.cik, t5.sic,t6.office,t6.industry, t2.country_code,t2.country_name, t2.is_clr,0,clock_timestamp(), rank() OVER (PARTITION BY mdm_id ORDER BY underlyingid) rnk FROM schema.v_table_name t2 JOIN schema2.v_table_name2 t4 ON t4.slice_id = v_slice_id AND t4.issuerid = t2.mdm_id JOIN schema.table_name3 t5 ON REPLACE(t4.underlyingid, '-RM', '') = UPPER(t5.ticker) left JOIN schema.table_name4 t6 ON t5.sic = t6.sic WHERE t2.list_id = v_list_id AND (t2.emt_status_id is null or t2.emt_status_id = 7) AND country_code = 840 ) alias11 WHERE rnk = 1) alias12; - Assistant