Q&A about the site for administrators, end users, developers and designers for Craft CMS
select top 10 u.id, (count(p.owneruserid) + count(c.userid)) as total from users u left join posts p on u.id = p.owneruserid left join comments c on u.id = c.userid where (datediff(year, current_timestamp, p.creationdate) <= 5 or datediff(year, current_timestamp, c.creationdate) <= 5) group by u.id, p.owneruserid, c.userid order by total desc