Subject What's wrong with this SQL?
Author Kjell Rilbe
Consider this SQL:

select
case when "RemovedAt" is null then 'Cur' else 'Hist' end "Category",
count(*) "Count"
from "Objects"
where "ObjectKind" = 92
group by case when "RemovedAt" is null then 'Cur' else 'Hist' end
order by case when "RemovedAt" is null then 'Cur' else 'Hist' end

Why would that SQL give me this error:

SQL Message : -104
Invalid token

Engine Code : 335544569
Engine Message :
Dynamic SQL Error
SQL error code = -104
Invalid expression in the select list (not contained in either an
aggregate function or the GROUP BY clause)

I've copied and pasted the group by clause into both order by and
select, so I think it should be alright.

Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64