[ https://issues.apache.org/jira/browse/METAMODEL-128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14385712#comment-14385712 ]
Kasper Sørensen commented on METAMODEL-128: ------------------------------------------- Good catch. If anyone wants to take a stab at it, I just reproduced it using this unittest which is now failing but should pass given a fix (I put it in QueryPostprocessDataContextTest): {code} public void testOrderOnAggregationValue() throws Exception { MockDataContext dc = new MockDataContext("sch", "tab", "hello"); Query query = dc.parseQuery("SELECT MAX(baz) AS X FROM tab GROUP BY baz ORDER BY X"); DataSet ds = dc.executeQuery(query); List<String> values = new ArrayList<String>(); while (ds.next()) { final String value = (String) ds.getRow().getValue(0); values.add(value); } ds.close(); // this should be alphabetically sorted assertEquals("[hello, world]", values.toString()); } {code} > Ordering on aggregation value not working > ----------------------------------------- > > Key: METAMODEL-128 > URL: https://issues.apache.org/jira/browse/METAMODEL-128 > Project: Apache MetaModel > Issue Type: Bug > Affects Versions: 4.3.2 > Reporter: Ashish Mukherjee > > I am using a CSV Data Context example with multiple fields - occurrences, > first_name, last_name. > The query - > SELECT SUM(persons.csv.occurrences) AS X, persons.csv.first_name FROM > ashish.persons.csv GROUP BY persons.csv.first_name ORDER BY X > This query always orders the results by first_name and not the aggregation > value. -- This message was sent by Atlassian JIRA (v6.3.4#6332)