UAR and AAR

0

Please login or register to vote for this query.

(click on this box to dismiss)

Hinduism

Q&A for followers of the Hindu religion and those interested in learning more about Hinduism

SELECT 
  DisplayName, UAR, AAR
FROM (
  SELECT
    u.DisplayName,
    (
      SELECT 
      (
        SUM(case when y.AcceptedAnswerId  > 0 AND y.Name = 'Question' then 1 else 0 end) * 100 / 
        SUM(case when y.Name = 'Question' then 1 else 0 end)
      )
      FROM (
      
        SELECT 
          p.AcceptedAnswerId,
          p.OwnerDisplayName,
          q.Name,
          (
            SELECT COUNT(*) FROM
            Votes v  
            INNER JOIN VoteTypes t ON t.id = v.VoteTypeId
            WHERE t.Name = 'AcceptedByOriginator'
            AND v.PostId = p.Id
          ) as isAccepted
        FROM Posts p
        INNER JOIN PostTypes q ON q.Id = p.PostTypeId
        WHERE p.OwnerUserId = u.Id
      
      ) as y
    ) as UAR,
    (
      SELECT 
      (
        SUM(case when y.isAccepted  > 0 AND y.Name = 'Answer' then 1 else 0 end) * 100 / 
        SUM(case when y.Name = 'Answer' then 1 else 0 end)
      )
      FROM (
      
        SELECT 
          p.AcceptedAnswerId,
          p.OwnerDisplayName,
          q.Name,
          (
            SELECT COUNT(*) FROM
            Votes v  
            INNER JOIN VoteTypes t ON t.id = v.VoteTypeId
            WHERE t.Name = 'AcceptedByOriginator'
            AND v.PostId = p.Id
          ) as isAccepted
        FROM Posts p
        INNER JOIN PostTypes q ON q.Id = p.PostTypeId
        WHERE p.OwnerUserId = u.Id
      
      ) as y
    ) as AAR
  FROM Users u
  WHERE u.Reputation > 20000
) as t

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results