Sql “产出”;“无”psycopg2数据库查询
0 我是SQL新手,目前正在尝试解决一个数据表问题 我有一个数据,现在需要首先找到请求导致错误的日期。它们作为时间戳从日志数据库中提取。然后检查状态,其中not status='200 OK',超过1%的请求导致错误的天数显示为count(*)>0.01,order by num desc 现在我的问题是,我没有得到任何显示的输出: 终端中的输出: -- 在>1%请求的日期之后,会导致错误: 没有 没有 代码: def编号1错误() """ 来自请求的错误百分比 计数错误和时间戳 输出: 头号错误 """ db=psycopg2.connect(数据库=dbname) c=db.cursor() c、 执行(“”) 非常感谢你Sql “产出”;“无”psycopg2数据库查询,sql,database,psycopg2,Sql,Database,Psycopg2,0 我是SQL新手,目前正在尝试解决一个数据表问题 我有一个数据,现在需要首先找到请求导致错误的日期。它们作为时间戳从日志数据库中提取。然后检查状态,其中not status='200 OK',超过1%的请求导致错误的天数显示为count(*)>0.01,order by num desc 现在我的问题是,我没有得到任何显示的输出: 终端中的输出: -- 在>1%请求的日期之后,会导致错误: 没有 没有 代码: def编号1错误() """ 来自请求的错误百分比 计数错误和时间戳 输出: 头号错
select oneerror.date_column, round(((cast(oneerror.request_error as decimal))/requests*1.0),2) as percent
from (select date(log.time) AS date_column,
count (*) as request_error
from log where not status = '200 OK'
group by date_column) as oneerror
join (select date(log.time) AS date_column,
count(*) as requests
from log
group by date_column) as total
on oneerror.date_column = total.date_column
where round((cast(oneerror.request_error as decimal)/requests*1.0),3)> 0.01
order by percent desc
''')
number_one_error = c.fetchall()
db.close()