Resource id #156
select count(*) from Ordens  a join CUP b on a.pEmi = b.pPId and b.iVer = a.fEmi join CUP c on a.pDest = c.pPId and c.iVer = a.fDest join TOper d on a.pTOper = d.pPId and d.iVer = a.fTOper left join Enderecos n on a.pDestEndEnt = n.pPId and n.iVer = n.iVAt left join CEPs o on n.pCEP = o.pPId and o.iVer = o.iVAt left join Cidades p on o.pCid = p.pPId and p.iVer = p.iVAt left join UFs q on p.pUF = q.pPId and q.iVer = q.iVAt left join CUP i on a.pRepCom = i.pPId and i.iVer = i.iVAt left join Ordens_ASC e on a.pWebNet = e.pPId and e.iVer = e.iVAt left join Ordens_FPgmto f on f.pOrdem = a.pPId and f.iVer = f.iVAt and f.lExc=0 left join PED_FPgmto_CPgmto g on f.pPED_FPgmto_CPgmto = g.pPId and g.iVer = (case when f.fPED_FPgmto_CPgmto=0 then g.iVAt else f.fPED_FPgmto_CPgmto end) and g.lExc=0 left join CPgmto h on g.pCPgmto = h.pPId and h.iVer = h.iVAt and h.lExc=0 where a.pPId in (select a.pOrdem from Ordens_Itens a,Itens b where a.pItem = b.pPId and b.iVer=b.iVAt and b.pSubGrpSku = 101 and a.iVer = a.iVAt) and a.lExc = 0 and a.iVer = a.iVAt and a.jTipo = 1 and a.lTriangulacao=0 and (a.tLibCom is not null or (a.jOrigem<>4 and a.lPreOrdCons=0))
iRegs=19735
iRegs=0