Badge Tenacious

2

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @UserId INT = ##userid## 

SELECT (SELECT Count(*) 
        FROM   posts 
        WHERE  owneruserid = @UserId 
               AND posttypeid = 2)                                        AS 
       "Total Respostas", 
       ( Count(a.id) )                                                    AS 
       "Score = 0", 
       ( Cast(Count(a.id) AS FLOAT) / (SELECT Count(*) 
                                       FROM   posts 
                                       WHERE  owneruserid = @UserId 
                                              AND posttypeid = 2) * 100 ) AS 
       "Porcentagem Aceitas" 
FROM   posts q 
       INNER JOIN posts a 
               ON q.acceptedanswerid = a.id 
WHERE  a.owneruserid = @UserId 
       AND a.posttypeid = 2 
       AND a.score = 0 
       AND a.owneruserid <> q.owneruserid

Enter Parameters

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