diff --git a/testing/groupby.test b/testing/groupby.test index 5af77e952..85a45d6a5 100755 --- a/testing/groupby.test +++ b/testing/groupby.test @@ -326,3 +326,23 @@ sneakers|sneakers|sneakers boots|boots|boots coat|coat|coat accessories|accessories|accessories} + +# make sure we return the group by key sorted DESC when the order by has only an aggregate term +do_execsql_test proper-sort-order { + SELECT u.first_name, COUNT(*) AS c + FROM users u + JOIN products p ON p.id = u.id + GROUP BY u.first_name + ORDER BY c DESC; +} {Travis|1 +Tommy|1 +Rachel|1 +Nicholas|1 +Matthew|1 +Jennifer|1 +Jamie|1 +Edward|1 +Daniel|1 +Cindy|1 +Aimee|1} +