Skip to content

Instantly share code, notes, and snippets.

@ABM-Dan
Created January 27, 2016 22:41
Show Gist options
  • Save ABM-Dan/21976382d0b505ed9f4c to your computer and use it in GitHub Desktop.
Save ABM-Dan/21976382d0b505ed9f4c to your computer and use it in GitHub Desktop.
$qb = $this->createQueryBuilder('l')
->leftJoin('l.sales', 's')
->where('l.is_active = 1')
->andWhere('s.sale_ts = (SELECT MAX(s2.sale_ts) FROM MyBundle:Sale s2 WHERE s2.location = l)')
->orderBy('l.id', 'ASC');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment