The Critter's
is (AFAICS?) equivalent to:\nSELECT\n mycalc = TO_CHAR(acolumn),\n count(*)\nFROM mytable\nGROUP BY\n TO_CHAR(acolumn)\n
\nSELECT\n TO_CHAR(acolumn) mycalc,\n count(*) freq\nFROM mytable\nGROUP BY\n TO_CHAR(acolumn)\n, which is equivalent to:
\nSELECT\n acolumnwithsomedamnlongstupidname myshortname,\n count(*) freq\nFROM mytable\nGROUP BY\n acolumnwithsomedamnlongstupidname\n-- this works, whereas
\nSELECT\n acolumnwithsomedamnlongstupidname myshortname,\n count(*) freq\nFROM mytable\nGROUP BY\n acolumnwithsomedamnlongstupidname myshortname\nor
\nSELECT\n acolumnwithsomedamnlongstupidname myshortname,\n count(*) freq\nFROM mytable\nGROUP BY\n myshortname\ndon't work, IIRC.
So, you could say that what makes it work or not, is that in the GROUP BY clause, you have to have "the original form" of what you are selecting -- whether that be "somedamnlongstupidcolumnname" or a calculation -- but NOT the alias you've specified for it in the SELECT clause.
(Though I must admit I'm not sure if this really holds for Critter's result_or_alias = calculation[_or_originalname?] form; I always use the originalname_or_calculation alias style, myself. But I think it's rather probable that this works the exact same way, because I'm guessing it is the exact same thing, only written differently.)
HTH!