Ratio of close questions for short questions

0

Please login or register to vote for this query.

(click on this box to dismiss)

Shows the counts of questions that are closed when the are under 50 charaters

Stack Overflow

Q&A for professional and enthusiast programmers

declare @questionPool table
(
  Id int not null,
  IsClosed bit not null
);

insert into @questionPool (Id, IsClosed) 
  select
    p.Id,
    case when ClosedDate is null then 0
         else 1
         end [IsClosed]
  from Posts p
  where p.PostTypeId = 1
  and len(p.Body) < 50; --question
  
declare @openCount int = (
  select count(1)
  from @questionPool qp
  where qp.IsClosed = 0
);

declare @closedCount int = (
  select count(1)
  from @questionPool qp
  where qp.IsClosed = 1
);

select
  @openCount [OpenCount],
  @closedCount [ClosedCount],
  (@openCount * 1.0 / @closedCount) [Open:Closed Ratio]

Enter Parameters

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