Question on min operation
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Question on min operation

Hybrid View

  1. #1
    Join Date
    May 2000
    Location
    Huntsville, AL. USA
    Posts
    52
    Is it possible to take the min of four minumum column results? Here is the scenario: I have four columns in a table which contain numbers. I want the minimum of the 4 number combination for each result, and also the maximum of the same. I try this in my select min(number1),min(number2),min(number3),min(number4) from table where .... and I get the minimum number in each column for the given where condition. The issue is, of those four numbers, I want the min (smallest) of the four results returned. I tried this "select min(min(number1),min(number2),min(number3),min(number4)) from table where .... " an got an invalid number of arguments. I was hoping it would be as simple as such (just adding a min outside) but it does not work. Is there a better way? I do not want the min in each column, but the min in each column where a condition is met.

  2. #2
    Join Date
    Sep 2001
    Location
    NJ, USA
    Posts
    1,287
    select min( least ( col1, col2, col3, col4)) from you_table [ where ...]

  3. #3
    Join Date
    May 2000
    Location
    Huntsville, AL. USA
    Posts
    52

    Thanks!

    Thanks a bunch! Knew there had to be a way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width