Your problem is the problem with the area. The GROUP BY is part of the statement table expression and therefore evaluated before the SELECT , that is, the projection. This means that your projected aliases are not available during grouping. This is one of the solutions.
SELECT DAY, MONTH, errormessage FROM ( SELECT TO_CHAR(dateTime, 'DD') DAY, TO_CHAR(dateTime, 'MM') MONTH, errormessage FROM log WHERE (...) ) GROUP BY MONTH, DAY, errormessage
this is different:
SELECT TO_CHAR(dateTime, 'DD') DAY, TO_CHAR(dateTime, 'MM') MONTH, errormessage FROM log WHERE (...) GROUP BY TO_CHAR(dateTime, 'MM'), TO_CHAR(dateTime, 'DD'), errormessage
Custom behavior
Note that some databases (including MySQL, PostgreSQL, and others) allow you to reference column aliases from the projection in the GROUP BY . In more strict SQL dialects (such as Oracle) that should not be possible, though
Lukas Eder
source share