Skip to content

Instantly share code, notes, and snippets.

@cleytonmessias
Created October 3, 2014 20:13
Show Gist options
  • Save cleytonmessias/e690769a1ca288362b1e to your computer and use it in GitHub Desktop.
Save cleytonmessias/e690769a1ca288362b1e to your computer and use it in GitHub Desktop.
SELECT
A.id,
A.name,
COUNT(B.id) as Total,
YEAR(delivery_date) AS ano,
MONTH(delivery_date) AS mes
FROM stores as A
INNER JOIN sales as B
ON A.id = B.store_id
GROUP BY YEAR(delivery_date), MONTH(delivery_date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment