Problem with find_by_sql()

I have a question concerning the method find_by_sql()..

i wonna to make a query like this:
"SELECT category, COUNT(*) FROM tables1"
but cannot return anything..
I want to know the correct procedure for the output in view..
In my trials I've found this:

Hello Gabriele,

Are you sure there is some data to return from the table? Check that
the find_by_sql call returns nil or has an array.

Why not skip the find_by_sql and use an ActiveRecord calculation
method? example:

category_counts = MyModelThatUtilizesTables1.count( :all,
  :group => ['category'],
  :order => ['category'])

You'll get back an array to process in your view. You can add

Then in your view check category_counts.nil? or category_counts.size
== 0 (can't remember if it returns nil or an empty array)


thanks so much..
but i wonna create a menu with all categories in tables..
for example:
Bio (3) -- numeber 3 are articles in table..with category = bio
Ruby (10) -- same as above but with category = ruby

In PHP I can have this result with a query..
I want this with RoR..

With your method is possible?

ps: I'm sorry for my english..