co powiesz na to?
SELECT CASE
WHEN org.size IN (0, 1) THEN '<26'
WHEN org.size = 2 THEN '26-50'
WHEN org.size = 3 THEN '51-100'
WHEN org.size = 4 THEN '101-250'
WHEN org.size = 5 THEN '251-500'
WHEN org.size = 6 THEN '501-1000'
WHEN org.size = 7 THEN '1001-5000'
ELSE '5000+' END AS Size, ....
Problem polega na tym, że grupujesz rekordy org.size
powodując <26
w dwóch różnych grupach, ponieważ pierwotnie są to 0
i 1
.
To zadziała,
GROUP BY CASE
WHEN org.size IN (0, 1) THEN '<26'
WHEN org.size = 2 THEN '26-50'
WHEN org.size = 3 THEN '51-100'
WHEN org.size = 4 THEN '101-250'
WHEN org.size = 5 THEN '251-500'
WHEN org.size = 6 THEN '501-1000'
WHEN org.size = 7 THEN '1001-5000'
ELSE '5000+' END