SELECT DISTINCT a.SETID , a.TREE_NAME , a.TREE_NODE , a.TREE_NODE_NUM , b.CATEGORY_ID , D.RANGE_FROM , D.RANGE_TO , D.DYNAMIC_RANGE FROM PSTREENODE a , PS_ITM_CAT_TBL b , PSTREEDEFN c , PSTREELEAF d 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_TYPE = b.CATEGORY_TYPE AND CATEGORY_ID = b.CATEGORY_ID AND CATEGORY_CD = b.CATEGORY_CD AND EFFDT <= %CurrentDateIn) AND b.EFF_STATUS = 'A' 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.SETCNTRLVALUE = SETCNTRLVALUE AND a.TREE_NODE_NUM = TREE_NODE_NUM AND a.TREE_NODE = TREE_NODE AND a.TREE_BRANCH = TREE_BRANCH AND a.EFFDT <= %CurrentDateIn) AND c.EFF_STATUS = 'A' AND C.TREE_STRCT_ID = 'ITEMS' AND a.SETID = D.SETID AND a.SETCNTRLVALUE = D.SETCNTRLVALUE AND a.TREE_NAME = D.TREE_NAME AND a.TREE_NODE_NUM = D.TREE_NODE_NUM AND a.TREE_BRANCH = D.TREE_BRANCH AND a.EFFDT = ( SELECT MAX(EFFDT) FROM PSTREELEAF WHERE a.SETID = SETID AND a.TREE_NAME = TREE_NAME AND a.SETCNTRLVALUE = SETCNTRLVALUE AND a.TREE_NODE_NUM = TREE_NODE_NUM AND a.TREE_BRANCH = TREE_BRANCH AND a.EFFDT <= %CurrentDateIn) AND D.RANGE_FROM <> ' ' AND D.DYNAMIC_RANGE = 'N'
|