Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transact SQL - Max value

Status
Not open for further replies.

747576

Programmer
Jun 18, 2002
97
GB
I have a table with rows containing columns of % values i.e pct1, pct2 etc. How do I find the max value from the different columns for each row, what is the function.

thanks in advance
 
Try something like:

SELECT CASE WHEN pct1 > pct2 AND pct1 > pct3 THEN pct1
WHEN pct2 > pct3 THEN pct2
ELSE pct3 END
FROM sometable


Core ANSI SQL-2003 compliant. (I know nothing about Transact SQL.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top