The list of fields in the select list have to be either also listed in the group by
list or be aggregate functions like count(*)
, max(amount)
, etc.
The problem is that you have not told Firebird what to do with POSPAY.TXNO
and POSPAY.AMOUNT
and it is not sufficient to tell what you do want to happen to them.
I suggest you remove those 2 fields from the query and have a select list of DEBTORS.COMPANY
, sum(POSPAY.AMOUNT)
as a starting point.