Home Forums SQL Server 2008 T-SQL (SS2K8) max value update RE: max value update
scottichrosaviakosmos
SSCommitted
Points: 1889
More actions
September 30, 2015 at 1:11 pm
#1830564
;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.