https://bugs.documentfoundation.org/show_bug.cgi?id=161144
--- Comment #2 from Hossein <hoss...@libreoffice.org> --- Code pointers: The relevant source code is inside wizards/com/sun/star/wizards/db/ and wizards/com/sun/star/wizards/query/ folders, and specifically the Java file wizards/com/sun/star/wizards/db/SQLQueryComposer.java contains most of relevant code. One should start from getSelectClause() method, and go step by step to see how query is being built: public String getSelectClause(boolean _baddAliasFieldNames) throws SQLException { .... } There are methods for Sortingcriteria, GroupByColumns, FromClause and AliasDisplayName. To fix the alias used in sorting, look into appendSortingcriteria(). The query summary is created in wizards/com/sun/star/wizards/query/QuerySummary.java, and it gives you hints where to look. For example, when getting this in summary: Sorting order: a (ASC), a (ASC) The code can be found by searching for "Sorting order:" which leads to RID_QUERY_51, that is found in wizards/com/sun/star/wizards/query/QuerySummary.java:60. The relevant code is directly inside setSummaryString() method: sSortingFraction = combinePartString("RID_QUERY_51", getSortFieldNames(), "RID_QUERY_52", "RID_QUERY_93", new String[] { "<FIELDNAME>", "<SORTMODE>" }) + sReturnChar; On the other hand, combineFieldNameFraction() creates this line, which is more complete: "Fields in the Query: a (Table1.a), a (Table2.a)" One can look into the above method, and create a similar method for sorting. -- You are receiving this mail because: You are the assignee for the bug.