SQL Sequence Abs and Neg Functions

The seq_abs()function returns a result sequence with the absolute values of the input sequence elements. The seq_neg() function returns a result sequence with the “negative” or opposite sign of the input sequence elements.

Following is an example script demonstrating the seq_abs() and seq_neg() functions:

 
    INSERT INTO SimpleSequence(testNumber,iVal1)
    VALUES(1,'{-3,-2,-1,0,1,2,3}');
     
    SELECT iVal1, seq_abs(iVal1) AS "abs" FROM SimpleSequence WHERE testNumber = 1;
    SELECT iVal1, seq_neg(iVal1) AS "neg" FROM SimpleSequence WHERE testNumber = 1;
     
    iVal1{}
    abs{}
    ---------------------------------------------------------
    {-3, -2, -1, 0, 1, 2, 3}
    {3, 2, 1, 0, 1, 2, 3}
     
    iVal1{}
    neg{}
    ---------------------------------------------------------
    {-3, -2, -1, 0, 1, 2, 3}
    {3, 2, 1, 0, -1, -2, -3}
     

Sample script

A sample script to demonstrate this select statement using xSQL can be run from the samples/xsql/scripts/financial directory with the following command:

     
    f 2