instruction: What is the average question score per view?. http://meta.stackexchange.com/questions/279418/what-is-the-average-question-score-per-view/279421#279421
response: SELECT SUM(CAST(scores AS INT)) AS sc, SUM(CAST(views AS INT)) AS vi, SUM(CAST(upvotes AS INT)) AS uv, SUM(CAST(downvotes AS INT)) AS dv FROM (SELECT p.Id AS id, Score AS scores, ViewCount AS views, SUM(CASE WHEN v.VoteTypeId = 2 THEN 1 ELSE 0 END) AS upvotes, SUM(CASE WHEN v.VoteTypeId = 3 THEN 1 ELSE 0 END) AS downvotes FROM Posts AS p INNER JOIN Votes AS v ON v.PostId = p.Id WHERE p.PostTypeId = 1 AND v.VoteTypeId IN (2, 3) GROUP BY p.Id, Score, ViewCount) AS allposts