SQL Sequence Modulo function

The seq_mod() function calculates the modulo (remainder after division) of the elements of sequence 1 by the corresponding elements of sequence 2.

Following is an example script demonstrating the seq_mod() function:

 
    INSERT INTO SimpleSequence(testNumber,dVal1,dVal2)
     
    VALUES(2,'{6,7}','{3,4}');
    SELECT dVal1,dVal2,seq_mod(dVal1,dVal2) As "mod" FROM SimpleSequence where testNumber=2;
     
    dVal1{}
    dVal2{}
    mod{}
    --------------------------------------------------------------------
    {6.000000, 7.000000}
    {3.000000, 4.000000}
    {0.000000, 3.000000}
     

So with the dataset above, the results are obtained as follows:

6.0 / 3.0 = 2.0 with remainder 0.0

7.0 / 4.0 = 1.0 with remainder 3.0

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 3