Q&A about the site for administrators, end users, developers and designers for Craft CMS
select top 10 u.id as [User Link], (count(p.owneruserid) + count(c.userid)) as Total_Posts_Comments from users u left join posts p on u.id = p.owneruserid left join comments c on u.id = c.userid where p.creationdate >= dateadd(year, -5, current_timestamp) group by u.id, p.owneruserid, c.userid order by Total_Posts_Comments desc