خرید بک لینک

Vote count: 0

I want to know how many upvotes a given user has obtained. It is like a history of the user, to record the user's total upvote everyday. However, I can only get a total score when the user's score changed. If the total score doesn't change, it shows missing value. (The code is a modified version from Stack exchange queries)

Declare @UserId int;
Select @UserId = ##UserId:int##; 
With
    upvotedQuestions As (
        Select v.CreationDate,
               Sum(Count(1)*5) Over (Order By v.CreationDate) As Score
            From Posts p
                 Ier Join Votes v
                On v.PostId = p.id
            Where v.VoteTypeId = 2 -- is an upvote
              And p.PostTypeId = 1 -- is a question
              And p.OwnerUserId = @UserId
            Group By v.CreationDate
    )
Select distinct
            v.CreationDate,
            upvotedQuestions.Score As [Upvote Question]

    From Votes v
        Left Outer Join upvotedQuestions On upvotedQuestions.CreationDate =v.CreationDate
    Where v.CreationDate >= (
            Select CreationDate
                From Users
                Where id = @UserId
            )
    Order By v.CreationDate
;

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 18 ارديبهشت 1395 ساعت: 8:19

صفحه بندی