>
how many tickets per agent, per queue
SELECT u.login user, sum(case when
q.id = 2 then 1 else 0 end) as Raw, sum(case when
q.id = 3 then 1 else 0 end) as Junk, sum(case when
q.id = 4 then 1 else 0 end) as Misc FROM `ticket` t left join users u on
u.id = t.user_id left join queue q on
q.id = t.queue_id group by
u.id
This will be a bit tedious to assemble, because it relies on specifying your individual list of queues:
This can help you generate:
SELECT CONCAT("SUM(CASE WHEN q.id=", id, " then 1 else 0 end) AS ", q.name, ", ") Query FROM `queue` q WHERE 1
Just remember the last entry before "FROM" must not have a comma.