• no problems.

    what i did was break out the login and logout sets and assign a row number to each login and log out. Then join this data back on userid and row number using a left join so where users that havent logged out can be defaulted to the date and time of running the SQL so you can calc the minutes passed for each login and logout.. then grouping by the userid allows you to sum all logins and logouts into one row

    hope ive explained well enough for you.

    🙂

    it could probably be written neater and with less code..

    if you have access top sql 2012 box there is a function called LEAD which can read forwards or backwards over rows making a job like this far easier.