select r.ref 'Resource ID',r.view_title_field 'Title',count(*) Downloads 

from

resource_log rl
join resource r on rl.resource=r.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 r.ref order by 'Downloads' desc