SELECT RA_MKT_CENTER , RA_PARENT_MKTCTR FROM PS_RA_UD_MKTCENTER WHERE ra_mc_level_num = 4 UNION SELECT RA_MKT_CENTER , 'ROOT' FROM PS_RA_UD_MKTCENTER WHERE ra_mc_level_num = 4 UNION SELECT DISTINCT a.RA_MKT_CENTER , b.RA_PARENT_MKTCTR FROM PS_RA_UD_MKTCENTER A LEFT OUTER JOIN PS_RA_UD_MKTCENTER B ON a.cs_institution=b.cs_institution WHERE a.ra_mc_level_num = 4 AND b.ra_mc_level_num=3 UNION SELECT RA_MKT_CENTER , RA_PARENT_MKTCTR FROM PS_RA_UD_MKTCENTER WHERE ra_mc_level_num = 3 UNION SELECT RA_MKT_CENTER , 'ROOT' FROM PS_RA_UD_MKTCENTER WHERE ra_mc_level_num = 3 UNION SELECT RA_MKT_CENTER , RA_PARENT_MKTCTR FROM PS_RA_UD_MKTCENTER WHERE ra_mc_level_num = 2 UNION SELECT RA_MKT_CENTER , RA_PARENT_MKTCTR FROM PS_RA_UD_MKTCENTER WHERE ra_mc_level_num = 1
|