I log errors in my websystem where people can log in from anywhere and for instance download things I share; family photos, dokuments ++.
It’s a overkill system, but as a developer I think it’s fun 😀
In my errortable i have the following structure:
DataTime Userid(int) IP(varchar) ErrorMessage(text)
In my persontable I have the following structure:
Id(int) Firstname(varchar) Lastname(varchar)
I want to count the number or errors, per different errors… but I think Im doing a mistake since the same user can have several IPs, and one IP can have several users. The SQL is the following:
SELECT TO_CHAR(DateTime, 'DD') DAY,
TO_CHAR(DateTime, 'MM') MONTH,
log.ErrorMessage,
CONCAT(CONCAT(person.lastname, ', '), person.firstname),
log.IP,
count(*) AS "COUNT"
FROM errorlog log
FULL JOIN person person
ON log.Userid = person.Id
WHERE log.DateTime BETWEEN foo
AND foo2
GROUP BY TO_CHAR(DateTime, 'MM'),
TO_CHAR(DateTime, 'DD'),
person.Lastname,
person.Firstname,
log.IP,
log.errormessage
ORDER BY MONTH ASC,
DAY ASC;
I think my sql might be grouping “away” same person on different IP.
Since you’ve included people’s names and ip address in your
SELECTclause it will be returning error count per error message per person per ip address per date.If you just want the error count per error message per date then omit people’s names and ip addresses from your query: