Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2010
    Posts
    1

    Question Unanswered: How to find maximum value of 3 columns?

    Hi,

    I have a table with 3 date columns and i want to find the maximum of 3 columns.

    For Ex:
    Table : EMPLOYEE(ID, Date1, Date2, Date3)

    Now i want to execute the query:
    SELECT ID, GREATEST(DATE1,, Date2, Date3) MAX_DATE FROM EMPLOYEE;

    But Informix doesn't have support for GREATEST() function.

    How can i do it in Informix?

    Thanks,
    Siva

  2. #2
    Join Date
    Apr 2010
    Posts
    3
    Hi,
    For lack of a better way, you can do this:

    create temp table test2
    (eid integer,
    date1 date);

    insert into test2 select eid, max(date1) from yourtable group by 1;
    insert into test2 select eid, max(date2) from yourtable group by 1;
    insert into test2 select eid, max(date3) from yourtable group by 1;

    select eid, max(date1) from test2 group by 1;

    if you need any other help, feel free to email: srubin36@gmail.com

Posting Permissions

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