22,181
社区成员




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 )