Create COUNT_FILTER function
Create COUNT_FILTER function

For example:
->addSelect('COUNT_FILTER(leads, WHERE leads INSTANCE OF :leadType) as leadCount')
pelex/DoctrineExtensions,nimasdj/DoctrineExtensions,pnvasanth/DoctrineExtensions