Q&A for Joomla! administrators, users, developers and designers
select distinct u.Id,(select count(*)
from PostTypes pt
join posts p on p.owneruserid=u.id
where pt.Name = 'Question'
and p.owneruserid=u.id) as NbQuestions,
count(b.id) as NbBadges, u.LastAccessDate
from Users u
join Badges b on u.Id = b.UserId
where u.DisplayName = 'John Snow'
group by u.ID, u.LastAccessDate
order by u.LastAccessDate desc