Question: How many respondents consider themselves to be "definitely" or "somewhat" a part of the Stack Overflow community by age in %?
SQL:
SELECT Age, COUNT(SOComm) * 100.0 / count2 FROM Responses JOIN (SELECT Age AS age2, COUNT(Age) AS count2 FROM Responses GROUP BY Age) ON age2 = Responses.Age WHERE SOComm = 'Yes, definitely' OR SOComm = 'Yes, somewhat' GROUP BY Age
SELECT Age, COUNT(*) AS Total, SUM(CASE WHEN SOComm IN ('Yes, definitely', 'Yes, somewhat') THEN 1 ELSE 0 END) AS PartOfSOCommunity, ROUND((SUM(CASE WHEN SOComm IN ('Yes, definitely', 'Yes, somewhat') THEN 1 ELSE 0 END) * 100.0) / COUNT(*), 2) AS Percentage FROM Responses WHERE NOT Age IS NULL GROUP BY Age ORDER BY Age