In SQL, to fetch the resultset the queries will be executed in the following order:
1. FROM clause
2. WHERE clause
3. GROUP BY clause
4. HAVING clause
5. SELECT clause
6. ORDER BY clause
In most of the RDBMS, this order explains which names (columns or aliases) are valid because they must have been introduced in the previous step.
Therefore in SQL Server and Oracle, you cannot use the term in the GROUP BY clause that you have defined in the SELECT clause because the GROUP BY is executed before the SELECT clause.