Skip to content

Instantly share code, notes, and snippets.

@manlycode
Created April 8, 2014 19:22
Show Gist options
  • Save manlycode/10175442 to your computer and use it in GitHub Desktop.
Save manlycode/10175442 to your computer and use it in GitHub Desktop.
SELECT DISTINCT(products.id), products.updated_at
FROM products
INNER JOIN lots
ON (lots.product_id = products.id)
GROUP BY products.id
HAVING SUM(lots.quantity) > 100;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment