SQL$HELP72.HLB  —  Conditional Expressions, SIGN Function
    SIGN returns an INTEGER value. SIGN accepts any numeric (fixed or
    floating) or interval value expression. If the value expression
    evaluates to NULL, then the SIGN function returns NULL. If the
    value expression evaluates to a negative value, then SIGN returns
    -1; if the value is positive then SIGN returns 1; otherwise a
    zero will be returned.

    Example: Using SIGN Builtin Function

    This example computes delayed departures from the LAYOVER table.

    SQL> select arr_date,
    cont>       dep_date,
    cont>       DECODE (SIGN ((dep_date - arr_date) day(9)),
    cont>           -1, 'date error - can not depart before arrival',
    cont>            0, 'same day departure',
    cont>            1, 'delayed')
    cont> from LAYOVER;

     2005-12-22   2006-01-20   delayed
     2005-12-23   2005-12-25   delayed
     2006-01-30   2006-02-01   delayed
     2006-02-06   2006-02-09   delayed
     2006-01-24   2006-01-26   delayed
     2006-02-02   2006-02-19   delayed
     2007-02-10   2007-02-16   delayed
     2007-02-20   2007-02-26   delayed
     2007-05-29   2007-06-08   delayed
     2007-06-12   2007-06-26   delayed
     2007-05-15   2007-05-21   delayed
     2007-09-10   2007-09-14   delayed
     2007-09-04   2007-09-06   delayed
     2007-09-19   2007-09-20   delayed
     2007-09-21   2007-09-24   delayed
    15 rows selected
Close Help