I have 6 records in a database. 3 from user 1, 2 from user 2 and 1 from user 3.
I want to count them by user_id so the final result would be 3. And it always returns count of all records from table. It returns 6.
My func:
return $this->getDeviceRepository()
->createQueryBuilder('tlu')
->select('COUNT(tlu.user_id)')
->getQuery()
->getResult();