diff options
author | Bertrand Chardon <bertrand.chardon@gmail.com> | 2012-04-13 12:08:03 -0700 |
---|---|---|
committer | Bertrand Chardon <bertrand.chardon@gmail.com> | 2012-04-13 12:08:03 -0700 |
commit | 418fb91269fe1114f9b8f170ff85e1ea851b8d0c (patch) | |
tree | 622641c3e8fe179896d5142aa7c105d493031392 /guides | |
parent | 38148a0642a998613f20849ea6a34803f8f3429d (diff) | |
download | rails-418fb91269fe1114f9b8f170ff85e1ea851b8d0c.tar.gz rails-418fb91269fe1114f9b8f170ff85e1ea851b8d0c.tar.bz2 rails-418fb91269fe1114f9b8f170ff85e1ea851b8d0c.zip |
SQL query formatting
Reformatted two SQL queries in Section 6) and 7) to avoid horizontal
scrolling where possible.
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/active_record_querying.textile | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/guides/source/active_record_querying.textile b/guides/source/active_record_querying.textile index de55401c1f..06d0aa4f74 100644 --- a/guides/source/active_record_querying.textile +++ b/guides/source/active_record_querying.textile @@ -539,7 +539,9 @@ And this will give you a single +Order+ object for each date where there are ord The SQL that would be executed would be something like this: <sql> -SELECT date(created_at) as ordered_date, sum(price) as total_price FROM orders GROUP BY date(created_at) +SELECT date(created_at) as ordered_date, sum(price) as total_price +FROM orders +GROUP BY date(created_at) </sql> h3. Having @@ -555,7 +557,10 @@ Order.select("date(created_at) as ordered_date, sum(price) as total_price").grou The SQL that would be executed would be something like this: <sql> -SELECT date(created_at) as ordered_date, sum(price) as total_price FROM orders GROUP BY date(created_at) HAVING sum(price) > 100 +SELECT date(created_at) as ordered_date, sum(price) as total_price +FROM orders +GROUP BY date(created_at) +HAVING sum(price) > 100 </sql> This will return single order objects for each day, but only those that are ordered more than $100 in a day. |