SELECT DISTINCT A.SETID1 , A.LEDGER_GROUP ,SP.SUBTYPE , C.SETID , C.CALENDAR_ID , C.BUDGET_PERIOD , B.LEDGER_GROUP , P.CALENDAR_ID , P.BUDGET_PERIOD FROM PS_CAL_BP_TBL C , PS_CAL_BP_TBL P , PS_KK_BUDGET_TYPE A , PS_KK_BUDGET_TYPE B ,PS_KK_SUBTYPE SP ,PS_KK_SUBTYPE SC WHERE A.SETID1=B.SETID1 AND B.LEDGER_GROUP=A.PARENT_BUDGET AND C.SETID=P.SETID AND P.CALENDAR_ID=SP.CALENDAR_ID AND C.CALENDAR_ID=SC.CALENDAR_ID AND C.BEGIN_DT>=P.BEGIN_DT AND C.END_DT<=P.END_DT AND A.EFFDT=( SELECT MAX(EFFDT) FROM PS_KK_BUDGET_TYPE WHERE LEDGER_GROUP=A.LEDGER_GROUP AND SETID1=A.SETID1 AND EFFDT<=%CurrentDateIn) AND B.EFFDT=( SELECT MAX(EFFDT) FROM PS_KK_BUDGET_TYPE WHERE LEDGER_GROUP=B.LEDGER_GROUP AND SETID1=B.SETID1 AND EFFDT<=%CurrentDateIn) AND A.EFF_STATUS='A' AND B.EFF_STATUS='A' AND SP.SETID1=B.SETID1 AND SP.LEDGER_GROUP=B.LEDGER_GROUP AND SP.EFFDT=B.EFFDT AND SC.SETID1=A.SETID1 AND SC.LEDGER_GROUP=A.LEDGER_GROUP AND SC.EFFDT=A.EFFDT AND SP.SUBTYPE=SC.PARENT_SUBTYPE
|