The user activity plugin uses:
'SELECT u.userid, count(p.postid) AS qs, count(p.selchildid) AS selected
FROM ^users u
LEFT JOIN ^posts p ON u.userid=p.userid AND p.type="Q"
WHERE u.handle=$';
I just need the count of best answers. How would you query it?
EDIT: The above gives the count() of how many answers of others the user selected.
To get the user's answers that has been selected the plugin uses:
'SELECT u.userid, COUNT(a.postid) AS qs, SUM(q.selchildid=a.postid) AS selected
FROM ^users u
LEFT JOIN ^posts a ON u.userid=a.userid AND a.type="A"
LEFT JOIN ^posts q ON a.parentid=q.postid AND q.type="Q"
WHERE u.handle=$';