SELECT DISTINCT A.STOCK_ID ,A.ST_BROKERAGE_ID ,B.DESCR FROM PS_STOCK_BRNCH_DTL A , PS_ST_BROKER_DTL B WHERE A.ST_BROKERAGE_ID = B.ST_BROKERAGE_ID AND A.EFFDT = ( SELECT MAX(AA.EFFDT) FROM PS_STOCK_BRNCH_DTL AA WHERE AA.STOCK_ID = A.STOCK_ID AND AA.ST_BROKERAGE_ID = A.ST_BROKERAGE_ID AND AA.ST_BRANCH_ID = A.ST_BRANCH_ID AND AA.EFFDT <= %CurrentDateIn) AND A.EFF_STATUS = 'A' AND A.CAPTIVE_OPTIONS = 'Y' AND B.EFFDT = ( SELECT MAX(BB.EFFDT) FROM PS_ST_BROKER_DTL BB WHERE BB.ST_BROKERAGE_ID = B.ST_BROKERAGE_ID AND BB.EFFDT <= %CurrentDateIn) AND B.EFF_STATUS = 'A'
|