Experts:
I need some assistance with designing a query which will calculate "total DB usage time" for each logged user.
Background:
- I just implemented a process where any user logins/logouts are appended to a table.
- Ultimately, I'd like to determine how much "total time" a user ([OSUserName]) has spent in the database.
Table Info:
- For simplification purposes, the attached sample table "T902_Admin_SystemUserTracking" includes eleven (11) records.
- Out of these 11 records, there are only 3 distinct users (clint.eastwood; jane.fonda; doris.day).
Envisioned Process:
- That is, for each user record, I want to perform basic arithmetic by subtracting the "Entry" date time stamp (DST) from the "Exit" date time stamp (DST). This should give me the net value of how many days, hours, & minutes a user's login instance lasted.
- Then, for each user (grouped), I want to sum up the total time of the net/delta value.
- Ideally, I'd like to have this accomplish in a single query.
- Output should be something like:
clint.eastwood: 1 day(s), 7 hour(s), 3 minute(s) ... or something like this
doris.day 0 day(s), 0 hour(s), 2 minute(s) ... or something like this
... I don't think I need to include seconds in the output.
Note:
- Please note that some DbExit times contain a null value. This indicates the user is currently in the database, so any null values in [DbExit] should probably be filtered out.
My question: What would this query look like?
Thank you,
EEH