Department Ticket Statistics SELECT B.name, count(A.id) as total from %%AGILE_DB_PREFIX%%ticket A join %%AGILE_DB_PREFIX%%ticket_department B on A.department_id=B.id A.site_id = %%DEFAULT_SITE%% GROUP BY name ORDER BY total DESC SELECT B.name, count(A.id) as total from %%AGILE_DB_PREFIX%%ticket A join %%AGILE_DB_PREFIX%%ticket_department B on A.department_id=B.id A.site_id = %%DEFAULT_SITE%% GROUP BY name ORDER BY total DESC 0 Department name true true true Tickets total true SELECT from_unixtime(A.date_orig,"%Y-%u") as yearmonth, count(A.id) as total, B.name from %%AGILE_DB_PREFIX%%ticket A left join %%AGILE_DB_PREFIX%%ticket_department B on A.department_id=B.id A.site_id = %%DEFAULT_SITE%% GROUP BY yearmonth ORDER BY yearmonth ASC