Hi everyone, I would like to create an agent login/logout report and make it nice and easy to read. The table I'm using has the login & logout times on separate rows (see example 1), but I would like to get each login and logout on the same row, preferably with the duration, but I'm stumped on how I can do this. If the login and logout data were on the same rows I could probably use some kind of case statement, but over multiple rows I'm lost. Could someone help?
Example 1 (Table)
Code
select (b.Firstname + ' ' + b.Lastname) as AgentName, AgentID, agenttimeutc,
convert(varchar, CAST(agenttimeutc AT TIME ZONE 'UTC' AT TIME ZONE 'GMT standard time' as datetime), 103) as Date,
convert(varchar(5), CAST(agenttimeutc AT TIME ZONE 'UTC' AT TIME ZONE 'GMT standard time' as datetime), 8) as Time,
propertyname, propertyvalue
from [I3_IC].[ININ_DIALER_40].[AgentStats] a
Inner Join [dbo].[Individual] b On a.agentid = b.ICUserID
Where datediff(day,agenttimeUTC,getdate()) = 1 and campaignname = 'GBR Test' and propertyname in ('Login', 'Logout')
order by Agentid, agenttimeUTC asc
Example output
Thank you for taking the time to look at my problem.
Kind regards