Migration rate


Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @from datetime = getdate() - 90,
        @PostMigratedHere tinyint = 36,
        @PostMigratedAway tinyint = 35,
        @MigrationRejected tinyint = 42,
        @Question tinyint = 1;
select count(*) as 'Migrated', 
       sum(iif(PostHistoryTypeId = @PostMigratedHere, 1,0)) 'To site',
       sum(iif(PostHistoryTypeId = @PostMigratedAway, 1,0)) 'Away from site',
       (select count(*)
        from Posts p
        where p.PostTypeId = @Question
        and p.CreationDate > @from), 2) as 'Migration %'
from PostHistory ph
where PostHistoryTypeId In (@PostMigratedHere, @PostMigratedAway)
      and ph.CreationDate > @from

Enter Parameters

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