Do you mean you want to know (A) how many seconds it was since the previous login, or (B) how many seconds each session is?
Date-time management is an area where many DBMS products are far from standard compliant! The SQL statements below are both ANSI/ISO standard compliant:
(A)[tt]
SELECT (login - (SELECT MAX(login) FROM loggtable AS l_sq
WHERE l_sq.user = l_main.user
AND l_sq.login < l_main.login)) SECOND(10)
FROM logtable AS l_main
[/tt]
(B)[tt]
SELECT (logout - login) SECOND(10)
FROM logtable
[/tt]
Note that USER is a reserved word in ANSI/ISO SQL. To avoid future problems when upgrading your DBMS, you'd better replace that column name, or double quote it (i.e. "user").
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.