1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| SELECT A.SessionID, A.TID, A.StartDate, A.Duration, A.MessageCount,
A.ErrorCount, A.Sent, A.Received,
L2.Msg
FROM ( SELECT S.ID AS SessionID, S.TID, S.CreationTime AS StartDate
, datediff(s, min(L.CreationTime), max(L.CreationTime)) AS Duration
, count(L.ID) AS MessageCount
, sum(L.Sev) AS ErrorCount
, sum(L.Sent) AS Sent
, sum(L.Received) AS Received
FROM TSessions S
LEFT OUTER JOIN TLog L
ON S.ID = L.SessionID
INNER JOIN Term T ON S.TID = T.TID
WHERE (S.CreationTime >= '28.06.2010' AND S.CreationTime < '28.07.2010')
GROUP BY S.ID, S.TID, S.CreationTime
) A
LEFT OUTER JOIN TLog L2
ON A.SessionID = L2.SessionID
ORDER BY A.SessionID DESC |
Partager