Getting the minimum of two values in SQL
SQL Server 2012 and 2014 supports IIF(cont,true,false) function. Thus for minimal selection you can use it like SELECT IIF(first>second, second, first) the_minimal FROM table While IIF is just a shorthand for writing CASE…WHEN…ELSE, it’s easier to write.