SELECT DISTINCT a.setid , a.tree_node , a.tree_name , b.descr60 FROM PSTREENODE a , ps_itm_cat_tbl b , pstreedefn c WHERE a.setid = b.setid AND a.tree_node = b.category_cd AND b.EFFDT = ( SELECT MAX(EFFDT) FROM PS_ITM_CAT_TBL WHERE SETID = b.SETID AND CATEGORY_ID = b.CATEGORY_ID AND EFFDT <= %CurrentDateIn) AND a.setid = c.setid AND a.tree_name = c.tree_name AND a.setcntrlvalue = c.setcntrlvalue AND a.effdt = ( SELECT MAX(effdt) FROM PSTREENODE WHERE a.setid = setid AND a.tree_name = tree_name AND a.effdt <= %CurrentDateIn) AND c.eff_status = 'A'
|