-
Notifications
You must be signed in to change notification settings - Fork 690
Closed
Description
I'm trying this query
SELECT country, COUNT(*) AS competitors
FROM foreignCompetitors
GROUP BY country
UNION
SELECT "Total: " AS country, COUNT(*) AS competitors
FROM foreignCompetitors
ORDER BY
CASE
WHEN country = "France" THEN 1
WHEN country = "Germany" THEN 2
WHEN country = "USA" THEN 3
WHEN country = "UK" THEN 4
ELSE 5
END;
But the ORDER BY clause isn't doing anything, as seen here:
But if I remove the CASE and just put the ORDER BY country it works, as seen here:
I can confirm that the CASE normally works in the ORDER BY clause, here an example query:
SELECT country, COUNT(*) AS competitors
FROM foreignCompetitors
GROUP BY country
ORDER BY
CASE
WHEN country = "France" THEN 1
WHEN country = "Germany" THEN 2
WHEN country = "USA" THEN 3
WHEN country = "UK" THEN 4
ELSE 5
END;
Results:
