I just did a few simple tests with mysql:
*) invalid tablename, invalid fieldname in sql:
Project project1 raised exception class 'ESQLDatabaseError' with message:
MySQL57Connection1 : Error executing query: Table 'accounts.users2' doesn't exist
*) valid tablename, invalid fieldname in sql:
Project project1 raised exception class 'ESQLDatabaseError' with message:
MySQL57Connection1 : Error executing query: Unknown column 'non_exisiting' in 'field list'
*) valid tablename and fieldname, but invalid TField.Fieldname connected to the TSQLQuery
Project project1 raised exception class 'EDatabaseError' with message:
SQLQuery1 : Field not found : "non_field"
You be the judge which error comes close to the error from OP:
"EDatabaseError. SQLQueryMain: Field not found: "gain_co"
If the error is in the SQL, the connector would return "Error executing query", which it doesn't in this case.
So there is simply a TField connected with Fieldname "gain_co" to the TSQLQuery, and the SQL doesn't contain that fieldname because Uncompress(gain_co) doesn't have "as gain_co" after it.