I have been trying to get bureau name and count.

show_graph_controller.rb

def index8
  @bureau=Incident.find(:all,:conditions=>"receipt_date LIKE
'2009-05%'",:select=>"distinct bureau_id,count
(*)",:group=>"bureau_id",:having=>"office_id=17")
end

index8.html.erb

<table>
<tr>
<th>Bureau name</th>
<th>Count</th>
<th>C</th>
<th>D</th>
</tr>
<tr>
<% @bureau.each do |incident| %>
<tr>
<td><%=h(Bureau.find(incident.bureau_id).name) %>台</td>
<td></td>
<td></td>
<td></td>
</tr>
<% end %>
</table>

How I can get count(*)?

I can get count(*) in SQL.

SELECT bureau_id,count(*) FROM incidents group by bureau_id having
office_id=17

Best regards,

Yoshida
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to