
Hallo,
um aussagekräftige Statistiken zu generieren, setzen wir Excel/ODBC mit Pivottabellen ein.
Hier mal ein SQL-Statement (MySQL), dass wir so ähnlich als Grundlage für alle Statistiken benutzen. Über das Ergebnis lässt sich eine entsprechende Pivottabelle generieren, die auch Ticketeingang nach Stunden rausschmeißt.
Gruß
Daniel
SELECT
DATE_FORMAT(th.create_time, '%Y-%m') as month
, WEEK(th.create_time, 3) as cw
, DATE(th.create_time) as dateFull
, DATE_FORMAT(th.`create_time`,'%H') as hour
, th.create_time as timestamp
, th.ticket_id
, if(ht.name = 'StateUpdate','AgentClose', ht.name) as event
, q.name as queue
, u.login as agent
FROM ticket_history th
INNER JOIN ticket_history_type ht ON ht.id = th.history_type_id
INNER JOIN queue q on q.id = th.queue_id
INNER JOIN users u ON u.id = th.create_by
WHERE
DATE(th.create_time) = CURRENT_DATE -- heute
-- DATE(th.create_time) = SUBDATE(CURRENT_DATE, INTERVAL 1 DAY) -- yesterday
-- DATE_FORMAT(th.create_time, '%Y-%m') = DATE_FORMAT(CURRENT_DATE, '%Y-%m') -- this month
/* (WEEK(th.create_time,3) = WEEK(CURRENT_DATE,3)
and YEAR(th.create_time) = YEAR(CURRENT_DATE)) */ -- current week
/* (WEEK(th.create_time,3) = WEEK(CURRENT_DATE,3)-1
and YEAR(th.create_time) = YEAR(CURRENT_DATE)) */-- last week
-- th.create_time BETWEEN '2010-07-31' AND '2010-08-31' -- time span
AND (
ht.id in (
1, -- NewTicket
12, -- EmailCustomer
6, 7 -- Forward, Bounce
, 8 -- send answer
, 13 -- PhoneCallAgent
, 14 -- PhoneCallCustomer
-- , 15 -- AddNote
, 16 -- Move
)
or (ht.id = 27 and th.state_id in (2,3)) -- AgentClose
)
-----Ursprüngliche Nachricht-----
Message: 1
Date: Mon, 4 Feb 2013 11:43:47 +0100
From: Grüning, Mario