Q&A for ebook publishers and readers
with data as ( select posttypeid, case when closeddate is null then 'open' else 'closed' end as status from Posts ) select posttypeid, status, count(*) from data group by posttypeid, status