Migration rate

0

Please login or register to vote for this query.

(click on this box to dismiss)

Game Development

Q&A for professional and independent game developers

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',
       round(100.0*count(*)/
       (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

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