StackOverflowDocumentation
.dbo
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
usp_Q7521
Parameters
Name
Type
Mode
@UserId
int
IN
Definition
CREATE PROC [dbo].[usp_Q7521] @UserId INT AS BEGIN /* Source: http://data.stackexchange.com/stackoverflow/query/7521/how-unsung-am-i */ -- How Unsung am I? -- Zero and non-zero accepted count. Self-accepted answers do not count. 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] from Posts q inner join Posts a on a.Id = q.AcceptedAnswerId where a.CommunityOwnedDate is null and a.OwnerUserId = @UserId and q.OwnerUserId != @UserId and a.PostTypeId = 2 END