In one case, the Query creator started a new Query as Query Type ACCOUNTS, and then added INCLUDE queries, but then later switched the Query type to NAMES.  Prior to version 5.0.19, TA may not update the SQL code, to correct all the joins and proper Select fields, and that caused the error.

Support suggests recreating the Query, and setting the correct Query type, and not changing it, if possible.