Users with the most quick votes by day

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

WITH sev as(


SELECT 
  row_number() over (partition by userID order by id) rn,
  UserId,
  CreationDate
FROM 
  SuggestedEditVotes sev
WHERE 
   UserID <> -1
  ), quickVotes as (
  
SELECT 
  
    sev.UserID,
    Count(sev.rn) k
    
FROM 
  sev 
  INNER JOIN sev s_prev
    ON sev.UserId = s_prev.UserID
       AND sev.rn = s_prev.rn + 1
WHERE
DATEDIFF(ss, s_prev.CreationDate, sev.CreationDate) < 5
GROUP BY 
sev.UserID)

SELECT 
     qv.UserID [User Link],
     qv.UserID,
     qv.k as QuickVoteCount,
     COUNT(sev.ID) TotalVotes
      
FROM 
quickVotes  qv
inner join  suggestedEditVotes sev
ON qv.userID = sev.userID 
GROUP BY 
     qv.UserID,
     qv.k
ORDER BY qv.K desc

Enter Parameters

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