# I have been trying to get bureau name and count

**URL:** <https://www.ruby-forum.com/t/i-have-been-trying-to-get-bureau-name-and-count/170407>\
**Category:** Rails\
**Created:** [June 17, 2009, 9:20am UTC](https://www.ruby-forum.com/t/i-have-been-trying-to-get-bureau-name-and-count/170407 "2009-06-17T09:20:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ykazu714](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/bc8723/32.png) [@ykazu714](https://www.ruby-forum.com/u/ykazu714)\
**Post date:** [June 17, 2009, 9:20am UTC](https://www.ruby-forum.com/t/i-have-been-trying-to-get-bureau-name-and-count/170407/1 "2009-06-17T09:20:07Z")

</div>

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

\<% @bureau.each do |incident| %\> \<% end %\>

| Bureau name | Count | C | D |
| --- | --- | --- | --- |
|
| |
| \<%=h(Bureau.find(incident.bureau\_id).name) %\>e$BBfe(B | | | |

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
