Referring alias name in subselect returns "Unknown column in 'where clause'"
For the alternative way to count these:

select
    day(date) as day,
    hour(date) as hour,
    count(1) as c,
    sum(a=1) as a1,
    sum(a=0) as a0,
    (sum(a=1) / count(1)) as pct
from t
group by hour, date(date)


I added the date to the group by so the same hour of different days do not get counted together - change that the way you need.