select
psperdno "期数",
count(case when psperdno = 1 then (case when date(datadate)-psduedt > 0 then a.custid end) else (case when date(datadate)-psduedt > 15 then a.custid end) end)
select
psperdno "期数",
count(case when psperdno = 1 then (case when date(datadate)-psduedt > 0 then a.custid end) else (case when date(datadate)-psduedt > 15 then a.custid end) end)