# SQL Sequence Order By Function

> The `seq_order_by()` function produces a sequence ordered according to the sequence specified in the second argument. In this example `seq_order_by()` is called explicitly to produce the sequence of close values in ascending order by volume.

> Following is an example script demonstrating the `seq_order_by()` function:

>         SELECT symbol, seq_search(day, 20130101, 20130331) as Q1_13,
>             seq_sort(volume@Q1_13, 'asc') as by_volume,
>             seq_order_by(close, by_volume) as "close order_by_vloume"
>         FROM Quote WHERE symbol='SYM0';

>         symbol
>         Q1_13{}
>         by_volume{}
>         close order_by_vloume{}
>         ------------------------------------------------------------------------------
>         SYM0
>         {20130101, 20130104, 20130106, 20130110, 20130123, 20130125, 20130129,
>           20130213, 20130214, 20130216, 20130311, 20130326}
>         {45, 48, 69, 335, 367, 385, 402,
>           420, 450, 732, 805, 808}
>         {74.730003, 50.369999, 57.730000, 62.830002, 80.919998, 25.920000, 53.459999,
>           37.279999, 29.940001, 67.870003, 80.320000, 45.790001}

> ## 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