Wednesday 20 May 2015

MSSQL - Max function that takes 2 valuse - like Math.Max in .NET

Watch this example on YouTube:


 Here is my table















the following statement will get the biggest value for each user, weather it is Bonus, Salary or Gambling
Select CustomerName ,
 (Select Max(Amount)
   From (Values (Bonus), (Salary), (Gambling)) as tblAllTotals(Amount))
From Table3

Here is my output

No comments:

Post a Comment