Loading ...
Sorry, an error occurred while loading the content.

How can I choose the max one from serveral varialbls

Expand Messages
  • yhdreamy
    Hi all: I want to choose the max one from five or more variables (int type). I hate to use IF...ELSE.. statements or use temperary tables. Is there anyway
    Message 1 of 3 , Jun 30, 2003
    • 0 Attachment
      Hi all:
      I want to choose the max one from five or more variables (int
      type).
      I hate to use "IF...ELSE.." statements or use temperary tables.
      Is there anyway else that I can do?
      Great thanks!
    • Michael Weiss
      I am not really sure what you mean by Select the max from five or more variables . By variables, do you mean columns in a table? If so, try something like:
      Message 2 of 3 , Jun 30, 2003
      • 0 Attachment
        I am not really sure what you mean by "Select the max from five or more
        variables". By variables, do you mean columns in a table? If so, try
        something like:

        SELECT Max(a.myfield) FROM mytable a

        That will get you the maximum value in the field 'myfield'. If this
        isn't what you need, could you show us a few rows of sample data, the
        field layout for your table, and a sample of how the results should
        look?
        Hth,
        Michael

        -----Original Message-----
        From: yhdreamy [mailto:zsdreamy@...]
        Sent: Monday, June 30, 2003 5:17 AM
        To: SQLQueriesNoCode@yahoogroups.com
        Subject: [SQLQueriesNoCode] How can I choose the max one from serveral
        varialbls

        Hi all:
        I want to choose the max one from five or more variables (int
        type).
        I hate to use "IF...ELSE.." statements or use temperary tables.
        Is there anyway else that I can do?
        Great thanks!










        To unsubscribe from this group, send an email to:
        SQLQueriesNoCode-unsubscribe@yahoogroups.com



        Your use of Yahoo! Groups is subject to
        http://docs.yahoo.com/info/terms/
      • jaggs0213
        In Oracle there exists a function called GREATEST which will return the largest value in a list of arguments. You could run a query like SELECT
        Message 3 of 3 , Jul 1, 2003
        • 0 Attachment
          In Oracle there exists a function called GREATEST which will return
          the largest value in a list of arguments. You could run a query like
          SELECT GREATEST(1,2,3,4) FROM DUAL; which would return 4. Or SELECT
          GREATEST(col1,col2,col3) FROM table_name; which would return the
          largest of the values in the 3 columns.

          Since you cite the datatype as INT, which is not an Oracle datatype,
          this may not help you.

          --- In SQLQueriesNoCode@yahoogroups.com, "yhdreamy" <zsdreamy@h...>
          wrote:
          > Hi all:
          > I want to choose the max one from five or more variables (int
          > type).
          > I hate to use "IF...ELSE.." statements or use temperary tables.
          > Is there anyway else that I can do?
          > Great thanks!
        Your message has been successfully submitted and would be delivered to recipients shortly.