How do you return 1 value per row of the max of several columns:
TableName
[Number, Date1, Date2, Date3, Cost]
I n
Above table is an employee salary table with salary1,salary2,salary3,salary4 as columns.Query below will return the max value out of four columns
select
(select Max(salval) from( values (max(salary1)),(max(salary2)),(max(salary3)),(max(Salary4)))alias(salval)) as largest_val
from EmployeeSalary
Running above query will give output as largest_val(10001)
Logic of above query is as below:
select Max(salvalue) from(values (10001),(5098),(6070),(7500))alias(salvalue)
output will be 10001