Please note. We cannot assist with custom queries. However you would need to join the topic table, which would then give you the forum ID. Something like this would give you the forum ID so you can then just add a where clause to limit as needed
select a.id1 as topic_id,t.forum_id,count(*) as total FROM core_attachments_map a inner join forums_topics t on t.tid = a.id1 where a.location_key = 'forums_Forums' group by a.id1 order by total desc