Just curious about SQL syntax. So if I have
SELECT
itemName as ItemName,
substring(itemName, 1,1) as FirstLetter,
Count(itemName)
FROM table1
GROUP BY it
Some DBMSs will let you use an alias instead of having to repeat the entire expression.
Teradata is one such example.
I avoid ordinal position notation as recommended by Bill for reasons documented in this SO question.
The easy and robust alternative is to always repeat the expression in the GROUP BY clause.
DRY does NOT apply to SQL.