我试图过滤掉网站错误率超过 1% 的日子。我已经有一个表格显示了各个日期及其各自的错误率,但是当我尝试包含“where”或“having”子句以过滤掉比率低于 0.01 的日期时,查询停止工作并显示我的专栏不存在,即使我之前声明了几个字符。这是代码:
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;
这是我得到的错误
ERROR: column "col1" does not exist
LINE 4: where col1 > 0.01
谢谢!!