Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Select MAX help

Author  Topic 

bulubuk1976
Starting Member

24 Posts

Posted - 2008-03-25 : 10:48:36
I have 3 columns with numeric values. I would like to add a fourth column that will capture the highest value from the first 3 columns. Here is an example of what I want:

YES NO N/A HIGHEST
60 20 20 60

Please help me with the syntax.

Thanks!

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-03-25 : 10:55:46
SELECT [Yes], [No], [N/A], (SELECT MAX(t) FROM (SELECT [Yes] AS t UNION ALL SELECT [No] UNION ALL SELECT [N/A]) AS d)
FROM Table1



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

bulubuk1976
Starting Member

24 Posts

Posted - 2008-03-25 : 11:24:31
Thank you so much! It works!
Go to Top of Page
   

- Advertisement -