Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 26, 2025

Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.

Original prompt

This section details on the original issue you should resolve

<issue_title>UNION with ORDER BY doesn't seem to work as expected</issue_title>
<issue_description>If I do

SELECT country, COUNT(*) AS competitors
FROM foreignCompetitors
GROUP BY country
ORDER BY country
UNION
SELECT "Total: " AS country, COUNT(*) AS competitors
FROM foreignCompetitors;

I get error: Parse error on line 6: ...Y countryORDER BY UNIONSELECT "Total: ---------------------^ Expecting 'LITERAL', 'BRALITERAL', 'LPAR', 'NUMBER', 'STRING', 'SHARP', 'DOLLAR', 'AT', 'VALUE', 'COLON', 'NOT', 'IF', 'PLUS', 'STAR', 'QUESTION', 'INSERTED', 'FIRST', 'LAST', 'DELETED', 'CURRENT_TIMESTAMP', 'CURRENT_DATE', 'JAVASCRIPT', 'NEW', 'CAST', 'CONVERT', 'SUM', 'TOTAL', 'COUNT', 'MIN', 'MAX', 'AVG', 'AGGR', 'ARRAY', 'REPLACE', 'DATEADD', 'DATEDIFF', 'TIMESTAMPDIFF', 'INTERVAL', 'TRUE', 'FALSE', 'NSTRING', 'NULL', 'EXISTS', 'ARRAYLBRA', 'BRAQUESTION', 'CASE', 'TILDA', 'MINUS', 'ATLBRA', 'LCUR', got 'UNION'

If I remove the ORDER BY clause it works.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UNION with ORDER BY doesn't seem to work as expected

2 participants