select
g.name 'Group Name',
count(rl.resource) 'Resource Downloads'

from
resource_log rl
left outer join user u on rl.user=u.ref
left outer join usergroup g on u.usergroup=g.ref
where
rl.type='d'
and rl.date>=date('[from-y]-[from-m]-[from-d]') and rl.date<=adddate(date('[to-y]-[to-m]-[to-d]'),1)
group by g.ref order by 'Resource Downloads' desc