The
seq_search_first()
andseq_search_last()
functions combine theseq_search()
andseq_first()
orseq_last()
to produce a sequence ordered according to the input sequence, starting with the value specified in the second argument and having the maximum number of values specified in the third argument.Following is an example script demonstrating the
seq_search_first()
andseq_search_last()
functions:SELECT symbol, seq_search_first(day, 20130101, 3) as "Q1_first3_13" FROM Quote WHERE symbol='SYM0'; symbol Q1_first3_13{} ------------------------------------------------------------------------------ SYM0 {20130101, 20130104, 20130106} SELECT symbol, seq_search_last(day, 20130301, 3) as "Q1_last3_13" FROM Quote WHERE symbol='SYM0'; symbol Q1_last3_13{} ------------------------------------------------------------------------------ SYM0 {20130101}In the example above, the “date” values
20130101
and20130301
(integer values in formatyyyymmdd
) are used to specify thefrom
andtill
dates for the sequence of day values in the first quarter of year 2013.Sample script
A sample script to demonstrate this
select
statement using xSQL can be run from thesamples/xsql/scripts/financial
directory with the following command:g 11