I was wondering why can\'t I use alias in a count(*) and reference it in the having clause. For instance:
select Store_id as StoreId, count(*) as _count
Probably because that's the way sql defines the namespaces. take, for example:
select a as b, b as a from table where b = '5' order by a
what do a and b refer to? The designers just chose to make the aliases only appear on the "outside" of the query.