1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Don't you lie to me!

This commit is contained in:
Ben Orenstein 2011-05-26 20:52:22 -04:00
parent dfba8f544b
commit 4807088fda

View file

@ -483,13 +483,13 @@ SQL uses the +HAVING+ clause to specify conditions on the +GROUP BY+ fields. You
For example:
<ruby>
Order.group("date(created_at)").having("created_at > ?", 1.month.ago)
Order.group("date(created_at)").having("created_at < ?", 1.month.ago)
</ruby>
The SQL that would be executed would be something like this:
<sql>
SELECT * FROM orders GROUP BY date(created_at) HAVING created_at > '2009-01-15'
SELECT * FROM orders GROUP BY date(created_at) HAVING created_at < '2009-01-15'
</sql>
This will return single order objects for each day, but only for the last month.