entityManager = $entityManager; } public function getMonthlyAveragePriceEvolutionApiPlatform(): array { $queryBuilder = $this->entityManager->createQueryBuilder(); $result = $queryBuilder ->select('MONTH(s.date) as month, YEAR(s.date) as year, AVG(s.amount / s.surface) as average_price') ->from(Sale::class, 's') ->groupBy('year, month') ->orderBy('year, month') ->getQuery() ->getResult(); return $result; } }