Q&A for speakers of other languages learning English
-- Enter Query Title -- Enter Query Description CREATE TABLE #days(Date datetime) INSERT INTO #days SELECT Votes.CreationDate FROM Votes, Users WHERE Users.Id = ##UserId## AND Votes.CreationDate >= Users.CreationDate GROUP BY(Votes.CreationDate) -- CREATE TABLE #rep(Date datetime, RecentUpvotes int, OldUpvotes int) CREATE TABLE #rep(one datetime, two datetime) DECLARE c CURSOR FOR SELECT * FROM #days ORDER BY Date; OPEN c DECLARE @day datetime FETCH NEXT FROM c INTO @day WHILE @@fetch_status = 0 BEGIN -- INSERT INTO #rep VALUES (@day, (SELECT COUNT(*) FROM Votes, Posts WHERE Votes.VoteTypeId = 2 AND Votes.PostId = Posts.Id AND Posts. INSERT INTO #rep VALUES (@day, @day + 1) FETCH NEXT FROM c INTO @day END CLOSE c DEALLOCATE c SELECT * FROM #rep