SELECT ; Customer.CustNo,; Customer.Name,; Invoice.InvNo,; Invoice.InvDate,; Invoice.InvAmt ; FROM ; Customer ; JOIN Invoice on Customer.CustNo=Invoice.CustNo ; WHERE ; DTOS(Invoice.InvDate)+STR(Invoice.InvNo,6) = ; (SELECT MAX(DTOS(InvTemp.InvDate)+STR(InvTemp.InvNo,6)) ; FROM Invoice InvTemp WHERE InvTemp.CustNo=Invoice.CustNo) ; INTO ; CURSOR resultIf you don't need any data from the Customer table, you can remove that from the field list and the JOIN of course.