My Answers with ViewCounts

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT TOP 1000
Questions.Id 
AS [Post Link],
ROW_NUMBER() OVER (ORDER BY Questions.ViewCount/(DateDiff(d, Questions.CreationDate, GetDate())) DESC,
                            Questions.ViewCount DESC) AS Row,
--Questions.Title,
Questions.ViewCount,
Questions.Score As QuestionScore,
Questions.AnswerCount, 
Questions.ViewCount/(DateDiff(d, Questions.CreationDate, GetDate())) As ViewsPerDay,
--AnswerDate,
DateDiff(d, AnswerDate, GetDate()) As AnswerDaysOld,
VoteCount As MyScore

FROM Posts AS Answers 
    INNER JOIN Posts AS Questions 
    ON Questions.Id = Answers.ParentId
    
    INNER JOIN Users AS Users
    ON Answers.OwnerUserId = Users.Id

    inner JOIN (select DisplayName, 
  Posts.ParentID,
  Posts.CreationDate as AnswerDate,
  Count(MyVotes.Id) as VoteCount
from Users 
  inner join Posts on Users.Id = Posts.OwnerUserId 
  left join (select * from Votes where VoteTypeId = 2) as MyVotes
              on Posts.Id = MyVotes.PostId
            where Users.Id = 3347858
              and PostTypeId = 2 --1 is Question and 2 is Answer
            group by Users.DisplayName, 
              Posts.ParentID,
              Posts.CreationDate) AS MyAnswers
     ON MyAnswers.ParentId = Questions.Id 

GROUP BY
Questions.Id, 
--Questions.Title,
Questions.AnswerCount, 
Questions.CreationDate,
Questions.ViewCount,
--Questions.FavoriteCount, 
Questions.Score,
Questions.LastActivityDate,
AnswerDate,
VoteCount

ORDER BY Questions.ViewCount/(DateDiff(d, Questions.CreationDate, GetDate())) DESC,
         Questions.ViewCount DESC

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results