instruction: How many of my answers are accepted?.
response: WITH Counts AS (SELECT CASE WHEN q.Id IS NULL THEN 0 ELSE 1 END AS IsAccepted FROM Posts AS a LEFT JOIN Posts AS q ON q.AcceptedAnswerId = a.Id WHERE a.PostTypeId = 2 AND a.OwnerUserId = '##UserId##'), Result AS (SELECT * FROM Counts PIVOT(COUNT(IsAccepted) FOR IsAccepted IN ('0', '1')) AS Result) SELECT '1' AS Accepted, '0' AS "not_accepted", 100 * '1' / CAST('0' + '1' AS FLOAT) AS Percentage FROM Result