Sqlserver Max with Over if you have alteast one entry in your table than this will be fastest Declare @tblMinMaxExample table ( pk integer not null identity(1,1) primary key, dataYearMonth integer, dataYear integer, dataMonth integer, recordedValue float, attributeA varchar(1), attributeB varchar(1) ) insert into @tblMinMaxExample values (201401, 2014, 1, 200.0, 'A', 'a') insert into @tblMinMaxExample select '201412', '2014', max(dataMonth) over(order by pk) , 100.0, 'L', 'l' from @tblMinMaxExample else use this Declare @tblMinMaxExample table ( pk integer not null identity(1,1) primary key, dataYearMonth integer, dataYear integer, dataMonth integer, recordedValue float, attributeA varchar(1), attributeB varchar(1) ) --insert into @tblMinMaxExample values (201...
Posts
Showing posts from October, 2018