Skip to content

Instantly share code, notes, and snippets.

@bigfoot90
Created October 27, 2015 04:38
Show Gist options
  • Select an option

  • Save bigfoot90/da3bd91fafb7b55a35c7 to your computer and use it in GitHub Desktop.

Select an option

Save bigfoot90/da3bd91fafb7b55a35c7 to your computer and use it in GitHub Desktop.
Returns the number of 'Audi', 'BMW' and 'Mercedes' cars grouped by year
SELECT
q.year,
(SELECT COUNT(q1) FROM AppBundle\Entity\CarPark q1 WHERE q1 = q AND q1.producer = "Audi") AS Audi
(SELECT COUNT(q1) FROM AppBundle\Entity\CarPark q1 WHERE q1 = q AND q1.producer = "BMW") AS BMW
(SELECT COUNT(q1) FROM AppBundle\Entity\CarPark q1 WHERE q1 = q AND q1.producer = "Mercedes") AS Mercedes
FROM AppBundle\Entity\CarPark q
GROUP BY q.year
ORDER BY q.year ASC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment