SELECT
AA.Subscription_Id
, AA.Wrls_Prod_Eff_Dt
, AA.Wrls_Prod_Cd
, AA.Wrls_Prod_Ds ,AA.RANK_ID
FROM
(
SELECT A.*, ROW_NUMBER () OVER (PARTITION BY Subscription_Id ORDER BY Wrls_Prod_Eff_Dt DESC) AS RANK_ID
FROM DW_NLIP_PRV_PLNS A
)AA
WHERE AA.RANK_ID = 1;
SELECT
AA.Subscription_Id
, AA.Wrls_Prod_Eff_Dt
, AA.Wrls_Prod_Cd
, AA.Wrls_Prod_Ds ,AA.RANK_ID
FROM
(
SELECT A.*, ROW_NUMBER () OVER (PARTITION BY Subscription_Id ORDER BY Wrls_Prod_Eff_Dt DESC) AS RANK_ID
FROM DW_NLIP_PRV_PLNS A
)AA
WHERE AA.RANK_ID = 1;