reference Date: 20.10.2015
step 1: need the max date from PayTO table > max(PayTO)
step 2: check if this max(PayTO) < reference Date (20.10.2015)
MenTBL
======
TZ | Fname
===========
11 | ZZZ
22 | XXX
33 | CCC
44 | VVV
PayTbl
======
TZ | PayTO
===========
11 | 01/01/2015
11 | 03/05/2015
11 | 06/01/2016
22 | 01/01/2015
22 | 01/10/2015
33 | 01/01/2015
33 | 01/12/2015
44 | 01/01/2015
44 | 04/05/2015
44 | 18/10/2015
The result should be that way:
22 | 01/10/2015 | XXX
44 | 18/10/2015 | VVV
Important note: PayTO is a string Field