WITH UserIds AS ( SELECT Id FROM Users WHERE Location LIK...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

WITH UserIds AS (
  SELECT Id FROM Users
  WHERE Location LIKE '%Iraq%'
  OR Location LIKE '%Syria%'
  OR Location LIKE '%Iran%'
  OR Location LIKE '%Libya%'
  OR Location LIKE '%Somalia%'
  OR Location LIKE '%Sudan%'
  OR Location LIKE '%Yemen%'
),
AllQuestionIds AS (
  SELECT Id QuestionId FROM Posts WHERE PostTypeId = 1 AND OwnerUserId IN (SELECT Id FROM UserIds)
  UNION 
  SELECT a.ParentId QuestionId FROM Posts a
    JOIN Posts q ON q.Id = a.ParentId
    WHERE a.PostTypeId = 2 AND a.OwnerUserId IN (SELECT Id FROM UserIds)
    AND (q.AcceptedAnswerId = a.Id OR a.Score >= 5 OR q.AnswerCount <= 3)
)
SELECT SUM(ViewCount) FROM Posts
WHERE Id IN (SELECT QuestionId FROM AllQuestionIds)

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results