Subject RE: [firebird-support] Select records by their position
Author sasha
>
> Is it possible to select some records from a table based on
> their positions?
> f.e.:
> F.e., if I want only the 1st, 2nd, 80th and 100th record from a table.
> I know the first/skip clauses, but they don't solve my problem(AFAIK)
>
Hi, in a nutshell, the answer is no.
If you have no experience with "relational databases", this may sound as
strange but a row of data (or a record if it sounds better for you) has no
position in a table. The positioning comes from ordering result sets with
order by clause, and if you want position in that set you should implement
it on client side, but I guess that's not what you asked for.
If you still want to get position (it's called rank, btw, google it up) from
server (again, not record position but position of row in result set) be
aware that it's going to be painfully slow on large sets so you must be
careful with that.

If you already have position column in your table then it's as trivial as
select * from something where position in (1, 2, 80, 100)
but of course, you should write some triggers to manage that column if you
want true "position".

Sasha