In Firebird I can group by case or group by UDF, so can PostGres do it.
Thank you, sorry for my English.