getEntityManager()); $qb->select('SUM(part_lot.amount)') ->from(PartLot::class, 'part_lot') ->leftJoin('part_lot.part', 'part') ->where('part.partUnit IS NULL'); $query = $qb->getQuery(); return $query->getSingleScalarResult(); } /** * Gets the number of parts that has price informations. * @return int * @throws \Doctrine\ORM\NoResultException * @throws \Doctrine\ORM\NonUniqueResultException */ public function getPartsCountWithPrice(): int { $qb = $this->createQueryBuilder('part'); $qb->select('COUNT(part)') ->innerJoin('part.orderdetails', 'orderdetail') ->innerJoin('orderdetail.pricedetails', 'pricedetail') ->where('pricedetail.price > 0.0'); $query = $qb->getQuery(); return (int) $query->getSingleScalarResult(); } }