List:General Discussion« Previous MessageNext Message »
From:Peter Brawley Date:February 2 2006 7:49pm
Subject:Re: How to Find the Max/Min from Multiple Columns (in each row)
View as plain text  
Henry,

>My question is that for each row, what's the sql query that determine the
>max value and the min value from all the columns??

SELECT ...
  GREATEST(col1,col2,...),
///

PB

-----

Henry Chang wrote:
> Hello everyone,
>
> I have a table where measurement values are collected in mulitple columns.
>
> Table Schema
> ==========================================
> ID, measurement_01, measurement_02, measurement_03
> ==========================================
> 1, 300, 350, 325    (max is 350, min is 300)
> 2, 225, 275, 400    (max is 400, min is 225)
> 3, 100, 500, 300    (max is 500, min is 100)
> ==========================================
>
> My question is that for each row, what's the sql query that determine the
> max value and the min value from all the columns??
>
> (I realize that each measurment should be it's own row, but I must use the
> table as it is.)
>
> Any help would be most appreciated.
>
> Thanks!
>
> Henry
>
>   
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.375 / Virus Database: 267.15.0/248 - Release Date: 2/1/2006
>   

Attachment: [text/html]
No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 267.15.0/248 - Release Date: 2/1/2006
Thread
How to Find the Max/Min from Multiple Columns (in each row)Henry Chang2 Feb
  • Re: How to Find the Max/Min from Multiple Columns (in each row)Peter Brawley2 Feb
  • Re: How to Find the Max/Min from Multiple Columns (in each row)Aleksandar Ivanisevic2 Feb
  • Re: How to Find the Max/Min from Multiple Columns (in each row)Harald Fuchs3 Feb