SQL Sequence Search Function

The seq_search() function produces a sequence ordered according to the sequence filtered by the range values specified in the second and third arguments.

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

 
    SELECT symbol, seq_search(day, 20130101, 20130331) as "Q1_13"
    FROM Quote WHERE symbol='SYM0';
     
    symbol
    Q1_13{}
    ------------------------------------------------------------------------------
    SYM0
    {20130101, 20130104, 20130106, 20130110, 20130123, 20130125, 20130129,
    20130213, 20130214, 20130216, 20130311, 20130326, 20130409}
     

In the example above, the “date” values 20130101 and 20130331 (integer values in format yyyymmdd) are used to return the sequence of day values for the first quarter of year 2013.

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:

     
    g 11