Subject Re: [firebird-support] select every nth row
Author Helen Borrie
At 01:37 PM 21/04/2009, you wrote:
>Have a database with a lot of data. To simplify plotting I would like to
>"filter" every nth row. Is there a way using a select statement to
>accomplish this?

Assuming you mean "sample" not "filter"....

With a selectable stored procedure or (with Fb 2 or higher) an executable block that outputs a set. In essence, you figure out the ordered set from which you want to take the sample, initialise a counter and loop through through the set incrementing the counter at each turn. Each time your counter reaches n, you fill the output row with the current data, SUSPEND, and re-initialise the counter.

./hb