Smallest value of three columns

  • Hi.

    I have created a query which joins three tables on a compound primary key. The resulting query has three "data" columns each containing a real (numeric) value representing a depth. I need to be able to find the minimum of the three.

    Anyone know how to do that?

  • select min(column name1 ) , min(column name 2),min(column name 3)

    kgunnarsson
    Mcitp Database Developer.

  • if you want 1 value from 3 columns:

    (case when col1 < col2 and col1 < col3 then col1

    when col2 < col1 and col2 < col3 then col2

    else col3 end) as colMin

  • That's it! Thanks.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply