Help with MIN field value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marc A. Lefebvre  US-775

    Help with MIN field value

    I have table FOO, fields F1, F2, F3, F4, and F5.

    I need a single SELECT statement on FOO that returns the LOWEST date
    between the five fields.


    So, if table records looked like

    FOO:
    F1 F2 F3 F4 F5
    3/25/03 3/12/03 3/10/03 3/15/03 3/22/03
    5/03/03 5/10/03 5/22/03 5/22/03 5/03/03
    9/10/03 9/09/03 9/12/03 9/01/03 9/15/03

    The select statement would return:
    3/10/03
    5/03/03
    9/01/03


    Again, this would need to work in a single select statement. If it is
    impossible, then if a stored procedure could be used, please show
    that.

    Thanks!!

    Marc
  • nobody

    #2
    Re: Help with MIN field value


    Look up LEAST function
    "Marc A. Lefebvre US-775" <lefebvre@iwave solutions.comwr ote in message
    news:5ef1a86c.0 309191233.79cdb 6b3@posting.goo gle.com...
    I have table FOO, fields F1, F2, F3, F4, and F5.
    >
    I need a single SELECT statement on FOO that returns the LOWEST date
    between the five fields.
    >
    >
    So, if table records looked like
    >
    FOO:
    F1 F2 F3 F4 F5
    3/25/03 3/12/03 3/10/03 3/15/03 3/22/03
    5/03/03 5/10/03 5/22/03 5/22/03 5/03/03
    9/10/03 9/09/03 9/12/03 9/01/03 9/15/03
    >
    The select statement would return:
    3/10/03
    5/03/03
    9/01/03
    >
    >
    Again, this would need to work in a single select statement. If it is
    impossible, then if a stored procedure could be used, please show
    that.
    >
    Thanks!!
    >
    Marc

    Comment

    • Ramesh

      #3
      Re: Help with MIN field value

      The select statement would be

      select least(f1,f2,f3, f4,f4) from foo;


      lefebvre@iwaves olutions.com (Marc A. Lefebvre US-775) wrote in message news:<5ef1a86c. 0309191233.79cd b6b3@posting.go ogle.com>...
      I have table FOO, fields F1, F2, F3, F4, and F5.
      >
      I need a single SELECT statement on FOO that returns the LOWEST date
      between the five fields.
      >
      >
      So, if table records looked like
      >
      FOO:
      F1 F2 F3 F4 F5
      3/25/03 3/12/03 3/10/03 3/15/03 3/22/03
      5/03/03 5/10/03 5/22/03 5/22/03 5/03/03
      9/10/03 9/09/03 9/12/03 9/01/03 9/15/03
      >
      The select statement would return:
      3/10/03
      5/03/03
      9/01/03
      >
      >
      Again, this would need to work in a single select statement. If it is
      impossible, then if a stored procedure could be used, please show
      that.
      >
      Thanks!!
      >
      Marc

      Comment

      Working...