更新时间:2022-02-21 21:58:28
另一种可能的解决方案:
Another possible solution:
select
a.userId,
sum(a.postStatus = 0) published,
sum(a.postStatus = 1) inactive,
sum(a.postStatus = 5) recalled,
sum(a.postStatus = 6) deleted,
b.unChecked
from userData a left outer join
(select userId, sum(poststatus = 10) unChecked
from userDataMod
group by userId)
b on a.userId = b.userId
where a.userId = 1;