• ;with mycte as (

    select * ,lag(sales,1)Over(Partition by countryid Order by stateid DESC) salesLag

    , row_number() Over(Partition by countryid Order by stateid DESC) rn from countrydetails )

    select * from mycte where rn=2

    I think its working.