该查询应该查找在特定日期发生的错误的百分比,但我在所有日期都得到相同的百分比。有什么方法可以从子查询返回多行。
select date(time) as day , ((select date(time) as day, from
log where status != '200 OK')/(select date(time) as day from log )) as views from
log group by day;
答案 0 :(得分:0)
尝试一下:
select
date(time) as day,
((count(*) filter(where status!=200)) /
count(*)::decimal(5,2))::decimal(5,2)
from log
group by day
答案 1 :(得分:0)
尝试一下
select date(time) as day , count(1) / tot_err as views
From log, (Select count(1) as tot_err from log where status != '200 OK')
Where status != '200 OK'
group by day;