Created
January 16, 2020 22:27
-
-
Save jammaloo/c13aa2cfaf103cc16f856ff948522bfc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple version | |
SELECT | |
username, | |
max(connected), | |
max(disconnected) | |
FROM radacct | |
GROUP BY username | |
# Using subqueries | |
SELECT | |
lc.username, | |
lc.last_connect, | |
dc.last_disconnect | |
FROM ( | |
SELECT | |
username, | |
max(connected) AS last_connect | |
FROM radacct | |
GROUP BY username) AS lc LEFT JOIN (SELECT | |
username, | |
max(disconnected) AS last_disconnect | |
FROM radacct | |
GROUP BY username) AS dc ON dc.username = lc.username | |
WHERE lc.last_connect <= dc.last_disconnect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment