I have a query where I chain two columns. Why does the alias not work in the GROUP BY clause but in ORDER BY clause, it does work? How can I write the select correctly?
SELECT
KOS_VER_ID AS "Vertrag"
, WHR_ISO_3_CODE AS "Waehrung"
, KOS_KOA_ST_KZN || ' - ' || ST_LANGBEZ_EN as "Kostenart"
, SUM (KOS_BETRAG) AS "Summe pro KOA"
FROM
KOSTEN
, WAEHRUNG
, SCHLUESSELTABELLE
WHERE
KOSTEN.KOS_VERHI_WHR_ID = WAEHRUNG.WHR_ISO_ID
AND KOSTEN.KOS_KOA_ST_KZN = SCHLUESSELTABELLE.ST_ID
AND KOS_VER_ID in (2509, 2510, 2511)
GROUP BY
KOS_VER_ID
, WHR_ISO_3_CODE
, KOS_KOA_ST_KZN || ' - ' || ST_LANGBEZ_EN
ORDER BY
"Vertrag"
, "Kostenart"
;

