Subject Re: [IBO] MasterLinks and to get the last records of detail query
Author Andreas Hesse
> I use 2 queries, a common master/detail relation.
> I use MasterLinks property and everything works fine.
>
> Now, I need to limit the number of record of the detail table to the
> last 5 records for each master record. I have no idea how to do it.
>
> If I need the first 5 record, then the solution is easy, in the detail
> SQL, I put "select first 5 * from detail" and it works fine, the
> problem is when I need the last 5.
>
> Any comment will be welcome. Thank you in advance
>
>

The first 5 records is only sensefull if you use an order by
statement, like:
select first 5 * from detail order by position ascending;

For the last change the order to descending.

select first 5 * from detail order by position descending;

If you need the last 5 in ascending order this sql can work (didn't
test it):

select * from (select first 5 * from detail order by position
descending) order by position ascending;

Andreas