I want to achieve

There are the following tables.
I'd like to make a table showing the city name, temperature average, daylight average, and energy_production average, but I don't know how to write the code, so please give me some advice.

Toppages_controller.rb that I thought of myself
class ToppagesController</pre>
<strong>Toppage # index that I thought about myself</strong>
  <th>City</th><th>Average Tempereture</th><th>Average Daylight</th><th>Average energy production</th>
  <% @ houses.each do | h |%>
  <td><% = h.city%></td>
  <td><% = h.average (: temperature)%></td>
  <td><% = h.average (: daylight)%></td>
  <td><% = h.average (: energy_production)%></td>
  <% end%>
Error with this code
  • Answer # 1

    It seems to be a surprisingly complicated problem.
    I haven't encountered it, but I found the following countermeasure article.

    Rewrite Mysql settings

    Narrow down the data to be acquired

    Such things are easy to hit when searching with an error sentence.
    There is no point in searching with information specific to this system, so if an error occurs in any system, hit the part that seems to be displayed and use it as a keyword.

    This time"functionally dependent on columns in GROUP BY clause
    Was used as a keyword.

    However, with this keyword, only Mysql articles will be hit, so if you want to narrow down to rails relatedrailsAlso add to adjust.

Related articles