SQL Sequence Ceil, Floor Functions

The seq_ceil() and seq_floor() functions take sequence arguments of type double and return a sequence of type double containing the values of the nearest integer below or above the input element value.

Following is an example script demonstrating the seq_ceil()and seq_floor() functions:

 
    INSERT INTO SimpleSequence(testNumber,dVal1)
    VALUES(4,'{2.9,3.14,4.6}');
     
    SELECT dVal1, seq_ceil(dVal1) AS "ceil" FROM SimpleSequence WHERE testNumber = 4;
    SELECT dVal1, seq_floor(dVal1) AS "floor" FROM SimpleSequence WHERE testNumber = 4;
     
    dVal1{}
    ceil{}
    ---------------------------------------------------------------
    {2.900000, 3.140000, 4.600000}
    {3.000000, 4.000000, 5.000000}
     
    dVal1{}
    floor{}
    ---------------------------------------------------------------
    {2.900000, 3.140000, 4.600000}
    {2.000000, 3.000000, 4.000000}
     

So the result values for this dataset are obtained as follows:

value ceil floor
2.90 3.00 2.00
3.14 4.00 3.00
4.60 5.00 4.00

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