You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ORDER BY LOWER(c) in a query grouped by LOWER(c) does not sort #2817
In a grouped query, ORDER BY with a function of the group key (ORDER BY LOWER(c) after GROUP BY LOWER(c)) does not sort. Ordering by the alias works, and the same ORDER BY without GROUP BY works.
Seen in the PostgreSQL regression tests run (alasql-pgsqltest) in select_having.sql and select_implicit.sql, for example SELECT lower(c), count(c) FROM test_having GROUP BY lower(c) HAVING count(*) > 2 OR min(a) = max(a) ORDER BY lower(c). Reproduced on develop (38bf3c3):
alasql('CREATE TABLE th (a INT, c TEXT)');alasql("INSERT INTO th VALUES (0, 'XXXX'), (1, 'bbbb'), (2, 'BBBB'), (3, 'cccc')");alasql('SELECT LOWER(c) AS l, COUNT(*) AS n FROM th GROUP BY LOWER(c) ORDER BY LOWER(c)');// [{l: 'xxxx', n: 1}, {l: 'bbbb', n: 2}, {l: 'cccc', n: 1}]alasql('SELECT LOWER(c) AS l, COUNT(*) AS n FROM th GROUP BY LOWER(c) ORDER BY l');// [{l: 'bbbb', n: 2}, {l: 'cccc', n: 1}, {l: 'xxxx', n: 1}]
Expected: the first query sorts like the second: bbbb, cccc, xxxx.
Activity