ID (self-generated number) IDFK (self-generated number) but can be repeated DATE (TO DATE) ...
ID IDFK FECHA
1 1 1/1/1999
2 1 1/2/1999
3 2 1/3/1999
4 3 1/2/1999
5 4 1/5/1999
6 4 1/3/1999
7 1 1/4/1999
Ok, think that the highest ID does not have to coincide with the later DATE, since there are more parameters that check if the row is valid to be taken.
I think I should do a subquery, but I'm not an expert at the moment for such a difficult query. This is my reason for asking for help. On the one hand I have to group by IDFK, and on the other hand I take the oldest date.
Also if it can be done in two consultations, I accept that solution
in this example the valid data would be
3 2 1/3/1999
4 3 1/2/1999
5 4 1/5/1999
7 1 1/4/1999
Thanks