How Unsung am I?

0

Please login or register to vote for this query.

(click on this box to dismiss)

Zero and non-zero accepted count. Self-accepted answers do not count.

Ask Different

Q&A for power users of Apple hardware and software

-- How Unsung am I?
-- Zero and non-zero accepted count. Self-accepted answers do not count.
DECLARE @MAXDATE DATETIME

SELECT @MAXDATE = MAX(Date)
FROM badges;

with newbies as
(
select top 100 * from badges where
name = 'Unsung Hero'
order by date desc
),
lastbadge as
(
select max(date) as date from newbies
)
select
    count(a.Id) as [Accepted Answers],
    sum(case when a.Score = 0 then 0 else 1 end) as [Scored Answers],  
    sum(case when a.Score = 0 then 1 else 0 end) as [Unscored Answers],
    sum(CASE WHEN a.Score = 0 then 1 else 0 end)*1000 / count(a.Id) / 10.0 as [Percentage Unscored],
    max(datediff(d, n.date, @MAXDATE)) as daybadge,
    min(datediff(d, a.creationdate, n.date)) as dayspost,
    min(datediff(d, v.creationdate, n.date)) as daysaccept
    
from
    Posts q
  inner join
    Posts a
  on a.Id = q.AcceptedAnswerId
  inner join newbies n on a.owneruserid = n.userid
  inner join votes v on v.postid = a.id and v.votetypeid=1
where
      a.CommunityOwnedDate is null
  and q.OwnerUserId != n.userid
  and a.postTypeId = 2 
  and a.creationdate<n.date
  and v.creationdate<n.date
group by n.userid

Enter Parameters

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