The
seq_add()
function adds the element from sequence 1 to the corresponding element of sequence 2; theseq_sub()
function subtracts the element of sequence 2 from the corresponding element of sequence 1; theseq_mul()
function multiplies the two corresponding elements; and theseq_div()
function divides the element of sequence 1 by the corresponding element of sequence 2.Following is an example script demonstrating the
seq_add()
,seq_sub()
,seq_mul()
andseq_div()
functions:INSERT INTO SimpleSequence(testNumber,dVal1,dVal2) VALUES(1,'{1,2}','{3,4}'); SELECT dVal1,dVal2,seq_add(dVal1,dVal2) As "add" FROM SimpleSequence where testNumber=1; SELECT dVal1,dVal2,seq_sub(dVal1,dVal2) As "sub" FROM SimpleSequence where testNumber=1; SELECT dVal1,dVal2,seq_mul(dVal1,dVal2) As "mul" FROM SimpleSequence where testNumber=1; SELECT dVal1,dVal2,seq_div(dVal1,dVal2) As "div" FROM SimpleSequence where testNumber=1; dVal1{} dVal2{} add{} -------------------------------------------------------------------- {1.000000, 2.000000} {3.000000, 4.000000} {4.000000, 6.000000} dVal1{} dVal2{} sub{} -------------------------------------------------------------------- {1.000000, 2.000000} {3.000000, 4.000000} {-2.000000, -2.00000} dVal1{} dVal2{} mul{} -------------------------------------------------------------------- {1.000000, 2.000000} {3.000000, 4.000000} {3.000000, 8.000000} dVal1{} dVal2{} div{} -------------------------------------------------------------------- {1.000000, 2.000000} {3.000000, 4.000000} {0.333333, 0.500000}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:f 3