Error: General ODBC Error: [Microsoft][ODBC SQL Server Driver][SQL Server]ORDER BY items must appear in the select list if SELECT DISTINCT is specified. Native error:145 when using a query that is based on another query or when merging queries

In a query, users have the ability to include the results of another query through Query Options. Users have found that when query is being used and the 'Select from query' option is enabled and populated, this error will occur. Therefore, it has been documented in Global Change & Delete, Export, Mail, Reports, Query Lists, and merging queries.  This error can also occur if you create a query from an import or report, and then add additional criteria fields to that query after. 

Download and install the latest patch, which contains all fixes from previous patches. If you are running an older version, download and install the latest version and then the patch. 

Alternative solutions:
  • Change the affected query to Static
  • Do not use the 'Select from query' option on queries. Attempt to create or merge the queries without using that Query Option. Depending on the merge scenario, using the functionality to add/remove groups of records within Query List may also work to group the desired records.
  • Do not add additional criteria to output queries
Note: Patch 2 for 7.93.5782 resolved this issue for the scenario of merging queries.

Environment

 7.93.5782
 7.93.5782, patch 4

Was this article helpful?