Jun21

Written by:David Aldridge
6/21/2011 3:59 PM 

This is done using the greatest() and least() functions respectively.  So to find the max across three columns then you would use something like:

select greatest(col1,col2,col3) from mytable;

To find the minimum you would use:

select least(col1,col2,col3) from mytable;

Tags:

1 comment(s) so far...

Re: MySQL min and max across columns

how can i show the column name where the max value found.

By mithun banik on  4/14/2014 2:08 AM

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment  Cancel 
You must be logged in and have permission to create or edit a blog.