22,219
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
select count( distinct a.id ) from OrderProductItem a where ( a.stauts= 2 and a.orgId= 10000 ) or (a.id in (select a.parentid from a where a.stauts= 0 and a.stauts_deliver= 22 group by a.parentid ))
select count(distinct id)
from
(
select id from OrderProductItem where stauts= 2 and orgId= 10000
union all
select a.id
from OrderProductItem a join OrderProductItem b
on a.id=b.parentid
where b.stauts=0 and b.stauts_deliver= 22
) t
--try:
select count( distinct a.id ) from OrderProductItem a ,a t
where (a.stauts= 2 and a.orgId= 10000 ) or (a.id=t.parentid and t.stauts= 0 and t.stauts_deliver= 22 )