I am trying to filter out days with more than 1% error rates for a website. I already have a table that shows the individual days with their respective error rates, but when I try to include a "where" or "having" clause to filter out the days with a ratio below .01, the query stops working and it says my column does not exist, even though I declared it a few characters before. This is the code:
select date(time) as day,
(trunc(cast(count(*) filter (where status similar to '%404%') as decimal) / count(*), 5)) as col1
from log
where col1 > 0.01
group by day
order by col1 desc;
This is the error i get
ERROR: column "col1" does not exist
LINE 4: where col1 > 0.01
Thanks!!