DECLARE @Need TABLE (question_id INT, timestamp datetime)...

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

-- Somebody upvote a -3 scored question after edit
DECLARE @Need TABLE (question_id INT, timestamp datetime)

DECLARE @Questions TABLE (question_id INT, action varchar(10), change INT, timestamp datetime)

DECLARE @last datetime
SET @last = (SELECT create_date FROM sys.databases WHERE name = 'StackOverflow')

BEGIN TRANSACTION
INSERT INTO @Need
SELECT q.id,
    q.CreationDate
from posts q
inner join Users u on q.OwnerUserId = u.Id
where q.PostTypeId = 1
  AND q.id between 74764459 and 74764469
  AND q.CreationDate > '2022-12-14'
  
-- 74764459 example with 1 vote score 2
DECLARE @qnum INT
SET @qnum = 74764459

INSERT INTO @Questions
SELECT e.postid, 'edit', 0, e.CreationDate
FROM PostHistory e
WHERE PostHistoryTypeId in (4, 5, 7, 8)
  AND postid between 74764459 and 74764469

INSERT INTO @Questions
SELECT v.postid, 'vote', 1, v.creationdate
FROM votes v
WHERE votetypeid=2
  AND postid between 74764459 and 74764469
COMMIT TRANSACTION

select * from @Questions
select * from @Need

-- SET @ii = 0
-- WHILE @ii < 100000 
--  BEGIN
--  INSERT  INTO @SecondTable
--  VALUES  (RAND() * 10000)
--  SET @ii = @ii + 1
-- END

Enter Parameters

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