Subject Re: [firebird-support] Skip records
Author Thomas Beckmann
I usually solve this kind of problem with recusive CTEs providing a
counter for the records returned, thus a "simple" select statement can
nicely filter on this kind of property without row numbers functionality.

Thomas

Am 28.07.2014 23:09, schrieb 'Leyne, Sean' Sean@...
[firebird-support]:
>
>
>
>
>> >>> On Jul 22, 2014, at 9:47 AM, "'checkmail' check_mail@...
>> >>> [firebird- support]" <firebird-support@yahoogroups.com> wrote:
>> >>> I would like to read every n record, depending on number of records.
>> >>
>> >> Do you care if your results are repeatable? If so, you'll have to
>> >> sort all the records then skip records in the result set.
>> >
>> >I don't think that the answer matters.
>> >
>> >Given that FB doesn't have the notion of ROW_Number within a result
> set, I
>> don't see how the OP can filter to only see every nth row.
>>
>> I thought this question was answered long ago (with MOD)... What about
>> something like:
>>
>> execute block returning(<resulting fields>) AS declare variable i integer;
>> begin
>> i = 0;
>> for select <whatever> into <resulting fields> do
>> begin
>> i = i + 1;
>> if (i = 2) then suspend;
>> if (i = 5) then i = 0;
>> end
>> end
>>
>> I think this will return record 2, 7, 12 etc.(of course there would
> have to be an
>> ORDER BY for the result to be repeatable.
>
> That certainly will work, but that is not a simple SELECT statement --
> which is what I thought that the OP wanted/was looking for.
>
> Sean
>
>

--
Mit freundlichen Grüßen,

Thomas Beckmann
Diplom-Informatiker


Wielandstraße 14c • 23558 Lübeck
Tel +49 (22 25) 91 34 - 545 • Fax +49 (22 25) 91 34 - 604
Mail thomas.beckmann@... <mailto:thomas.beckmann@...>

ASSFINET-Logo

*ASSFINET Dienstleistungs-GmbH*
Max-Planck-Straße 14 • 53501 Grafschaft bei Bonn
info@... <mailto:info@...> • www.assfinet.de
<http://www.assfinet.de/>

Geschäftsführer: Dipl. Wirtschaftsinformatiker Marc Rindermann
Registergericht Koblenz HRB 23331

Diese E-Mail enthält vertrauliche Informationen. Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben,
informieren Sie bitte sofort den Absender und vernichten Sie diese Mail.
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist
nicht gestattet.