sql - TSQL retrieve maximum row based on a combination of the largest of other columns -
i have table in sql server 2012 contains patch notes different versions of software. table looks this:
versionid int primarykey identity major tinyint minor tinyint revision tinyint patchnotes nvarchar(max)
i need retrieve row recent version based on major, minor , revision. example, version 1.1.4 comes after version 1.1.3 before version 1.2.1.
would have ideas on how write query in tsql this? if maybe push me in right direction without completing entire query, i'd appreciative. trying learn , that!
i order 3 fields descending , take 1 record:
select top 1 versionid, major, minor, revision, patchnotes versions order major desc, minor desc, revision desc
multiple sort columns can specified. sequence of sort columns in order by
clause defines organization of sorted result set. result set sorted first column , ordered list sorted second column, , on.
Comments
Post a Comment