Q&A for administrators, end users, developers and designers for Craft CMS
select Id, Location, c from Users join (select top 1000 OwnerUserId, COUNT(OwnerUserId) as c from PostTags as pt join Posts as p on p.Id = pt.PostId where OwnerUserId > 0 AND pt.TagId = 17 AND PostTypeId = 1 group by OwnerUserId order by c desc) as q on Users.Id = q.OwnerUserId where Location is not null order by c desc;