-- W01・最新の資格Bを送った現場数 select count(distinct site) from receipts join master using(worker) where doc=current_doc and worker="W01"; -- W01・最新の資格Bが受理された現場数 select count(distinct site) from receipts join master using(worker) where doc=current_doc and worker="W01" and status="受理"; -- 差戻しを返す現場・対象版 select site,doc,status from receipts join master using(worker) where doc=current_doc and status="差戻し";