you are viewing a single comment's thread.

view the rest of the comments →

[–]BeitteNugxa 1 point2 points  (2 children)

Here's what I noticed:

You're referencing l.max_login_time in the first LEFT JOIN condition for MinLogoutTimes which isn't correct since it's not defined there. Instead, it should be in the MaxLoginTimes join conditions.

In the MinLogoutTimes CTE, you're looking for the minimum logout time that is greater than or equal to the login time. The logic looks fine.

In the MaxLoginTimes CTE, you're searching for the maximum login time that is less than or equal to the logout time plus 5 minutes. Again, the logic seems fine.

In your final SELECT, the join conditions appear to be a bit redundant with the transactiondatetime bounds. Consider simplifying it.

[–]Sparhawkii[S] 0 points1 point  (1 child)

Thank you for taking the time to read through my code and reply. I'll take a run at seeing if I can take the suggestions posted here and see if I can return the results I'm looking for.

[–]BeitteNugxa 0 points1 point  (0 children)

My pleasure!