instruction: Lists all users which answered the same questions as I did and compare the scores. Lists all users which answered the same questions as I did and compare the scores
response: SELECT oa.OwnerUserId AS "user_link", COUNT(*) AS "total_answers", SUM(CASE WHEN AcceptedAnswerId = ma.Id THEN 1 ELSE 0 END) AS "ma_accepted", SUM(CASE WHEN AcceptedAnswerId = oa.Id THEN 1 ELSE 0 END) AS "oa_accepted", NULLIF(SUM(CASE WHEN AcceptedAnswerId = ma.Id THEN 1 ELSE 0 END), 0) / NULLIF(SUM(CASE WHEN AcceptedAnswerId = oa.Id THEN 1 ELSE 0 END), 0) * 100.0 AS "ratio", SUM(ma.Score) AS "ma_total_score", SUM(oa.Score) AS "oa_total_score", NULLIF(SUM(ma.Score), 0) / NULLIF(SUM(oa.Score), 0) * 100.0 AS "ratio" FROM Posts AS ma INNER JOIN Posts AS qu ON ma.ParentId = qu.Id INNER JOIN Posts AS oa ON qu.Id = oa.ParentId AND ma.Id != oa.Id WHERE ma.PostTypeId = 2 AND ma.OwnerUserId = '##UserId##' AND NOT oa.OwnerUserId IS NULL GROUP BY oa.OwnerUserId