Last active
August 29, 2015 14:10
-
-
Save PlaidShirtPat/f8f37f0bd8d6524cb90c to your computer and use it in GitHub Desktop.
sql issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Two tables: | |
| Categories | |
| :id, | |
| :name | |
| Instances | |
| :id, | |
| :category_id, | |
| :another_id, | |
| :quantity | |
| Category. | |
| joins('LEFT JOIN "instances" ON "instances"."category_id" = "categories"."id"'). | |
| select("SUM(instances.quantity) as quantity, "). | |
| group("instances.category_id") | |
| But I need to filter by :another_id and I have no idea how to without removing some categories without any instances with that id |
Author
PlaidShirtPat
commented
Dec 4, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment