Topic: Re: Penultimate record

In tables there is no concept "the last" or "penultimate" record (all depends on sorting and record can be penultimate on date/time, value of any field) and query design for this purpose not is necessity. It would be desirable to know by what criterion penultimate (and it can be simple you want to receive value of any field from last on saving time (or by other criterion) records?  it would not be desirable-describe the task which you solve)


Re: Re: Penultimate record

_ wrote:

It is necessary to get penultimate record.

As it is already told above, the concept of the order of records in itself - does not exist. It appears only after sorting (and records on sorting expression should be unique) will be specified. Only at any explicit sorting there is an order and, accordingly, concept of penultimate record.
Standardly in Aksesse penultimate record receive so:

FROM some_table
ORDER BY some_field DESC
ORDER BY some_field ASC

I.e. in a subquery at reverse sorting take 2 first records (at normal sorting it will be 2 last), then in exterior request already at direct sorting take the first record (as in a subquery everything, except two last, are discarded, it is that record which was penultimate).