Last active
September 2, 2018 20:24
-
-
Save ikzekly/ad363b8dcdb7a067840ef5923caa0249 to your computer and use it in GitHub Desktop.
Take all users, who having five and less invoices
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
User.joins('LEFT JOIN "invoices" ON "invoices"."merchant_id" = "users"."id"').group("users.id").having("count(*) <= ?", 5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment