Ruby on Rails Sunday, January 18, 2015

When I tried on mysql
  select max(peak_kw) peak,month from sola_daylies group by month;
It returns as I expected
+--------+------------+
| peak   | month      |
+--------+------------+
| 0.2126 | 2014-12-01 |
| 1.6156 | 2015-01-01 |
+--------+------------+

on rails console,
  Sola::Dayly.find_by_sql("select max(peak_kw) peak,month from sola_daylies group by month")
log says, it makes sql command
  select max(peak_kw) peak,month from sola_daylies group by month
It returns without column "peak"
[#<Sola::Dayly id: nil, month: "2014-12-01">, #<Sola::Dayly id: nil, month: "2015-01-01">]

Sola::Dayly.select("max(peak_kw) peak",:month).group(:month)
returns same.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/bc0502aa-61d2-42a2-a35e-df42ebf7fcee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment