Q&A for scientific skepticism
select x.cdate, x.posttypeid, x.dreason, count(x.id) as cnt from ( select id , cast(creationdate as date) as cdate , posttypeid , case when (deletiondate <= '2023-12-03' and parentid is not null) then 'Ans' when (deletiondate <= '2023-12-03' and parentid is null) then 'Que' else 'Ali' end as dreason from postswithdeleted where creationdate = '2022-12-02' and posttypeid in ('1', '2') ) x group by x.cdate, x.posttypeid, x.dreason ;