Subject Re: [firebird-support] last of the SQL
Author Ismael L. Donis García
If, I believe that this is the best-suited form to do the trick.

Thank you very much.

¦¦ ISMAEL ¦¦

----- Mensaje original -----
De: Svein Erling Tysvær
Enviado: miércoles, 30 de septiembre de 2009 01:56
Asunto: RE: [firebird-support] last of the SQL

Firebird works on data sets and in a set there is no default understanding of FIRST or LAST. So there are several possible answers to your question:

This gets the last address alphabetically sorted according to the current collation:

select, max(staff.address) as address from staff
group by order by

This gets the last address depending on MoveDate, or the highest primary key if a person moved twice on the same date (OK, that's unlikely, but in different situations it may be good to know how to randomly pick one in case of equality):

select, s1.address from staff s1
where not exists(select * from staff s2
where =
and (s2.MoveDate > s1.MoveDate
or (s2.MoveDate = s1.MoveDate
and s2.PrimaryKeyField > s1.PrimaryKeyField)))


-----Original Message-----
From: [] On Behalf Of Ismael L. Donis Garc?a
Sent: 24. september 2009 09:51
Subject: [firebird-support] last of the SQL

What show substitutes the show last of the SQL?

Example: select, last(staff.address) as address from staff group
by order by

¦¦ ISMAEL ¦¦

[Non-text portions of this message have been removed]