From: | Mark Mitchell <mark(at)lapcrew(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Nth Select |
Date: | 2003-02-21 00:19:17 |
Message-ID: | 1045786757.22003.0.camel@sql.icnfull.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
I'm currently doing an Nth select to filter records as they come back
from the database. The Nth works like this,
A query is built that returns 2000 results but the user only wants to
see 500.
To give each row a fair chance we cannot simply use LIMIT 500 instead we
get a value for each row by dividing the the number of rows we want to
see by number of row returned.
So - 500 / 2000 is .25
Now as we return the results we count the value of each row until its
greater than or equal to 1. The counter is then reset and the counting
continues.
Row 1 - Counter is .25
Row 2 - Counter is .50
Row 3 - Counter is .75
Row 4 - Counter is 1 we keep this row and reset the counter.
Row 5 - Counter is .25
and so on.
Is there any way this can be done by the database before the results are
returned to my program?
Thanks for any help or pointers.
- Mark
From | Date | Subject | |
---|---|---|---|
Next Message | εεδΈ | 2003-02-21 03:35:40 | Fw: |
Previous Message | Jeff Boes | 2003-02-20 20:59:19 | Re: EXCEPT Queries |