I'm new to SQL and currently try to resolve a data table problem.
I have a data table and now need to find firstly the dates, on which a request lead to an error. They are pulled as timestamps from the log database. Afterwards the status is checked where not status = '200 OK' and the days on which more than 1% of requests lead to an error are shown having count(*) > 0.01,order by num desc.
def number_one_error():
"""
Percentage of errors from requests
Counting errors and timestamps
Output:
number one errors
"""
db = psycopg2.connect(database=dbname)
c = db.cursor()
c.execute('''
select date
from (select date(log.time) AS date_column,
count (*) as request_error
from log where not status = '200 OK'
group by log.time) as oneerror
join (select date(log.time) AS date_column,
count(*) as requests
from log
group by log.time) as total
on oneerror.date_column = total.date_column
where (round(((oneerror.request_error)/all_requests),3> 0.01))
''')
number_one_error = c.fetchall()
db.close()
psycopg2.ProgrammingError: column "date" does not exist
LINE 2: select date