Total upvotes/downvotes from anonymous feedback

0

Please login or register to vote for this query.

(click on this box to dismiss)

Mathematics

Q&A for people studying math at any level and professionals in related fields

SELECT
  COUNT(pf.Id) AS Total,
  SUM(Case When pf.VoteTypeId = 2 Then 1 Else NULL End) AS UpFeedback,
  SUM(Case When pf.VoteTypeId = 3 Then 1 Else NULL End) AS DownFeedback,
  SUM(Case pf.VoteTypeId When 2 Then 1 WHEN 3 Then -1 End) AS [Difference],
  ROUND((CAST(SUM(Case When pf.VoteTypeId = 2 Then 1 Else NULL End) AS decimal))*100.0/(CAST(COUNT(pf.Id) AS decimal)),2) AS PercUp,
  ROUND((CAST(SUM(Case When pf.VoteTypeId = 3 Then 1 Else NULL End) AS decimal))*100.0/(CAST(COUNT(pf.Id) AS decimal)),2) AS PercDown,
  ROUND((CAST(SUM(Case pf.VoteTypeId When 2 Then 1 When 3 Then -1 End) AS decimal))*100.0/(CAST(COUNT(pf.Id) AS decimal)),2) AS PercDiff
FROM
  PostFeedback pf

Enter Parameters

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