Equivalent ruby syntax for this query.

Book.find(:all,
          :conditions=>["release_date >= ? and release_date < ? and
book_type='New'",@date[:from],@date[:to]],
          :group=>"auther_id",
          :order=>"count(*) desc",
          :select=>"auther_id,sum(case when auther_type = 'New' "+
      "then 1 else 0 end) as new,sum(case when auther_type != 'New' then
1 else 0 end) as review,count(*) as total")

in the above query how to write the "case" conditions in ruby query.

can anyone tell me which is the equivalent ruby syntax for this

sum(case when auther_type != 'New' then 1 else 0 end) as review

thanks in advance
Jk

Book.find(:all,
:conditions=>["release_date >= ? and release_date < ? and
book_type='New'",@date[:from],@date[:to]],
:group=>"auther_id",
:order=>"count(*) desc",
:select=>"auther_id,sum(case when auther_type = 'New' "+
"then 1 else 0 end) as new,sum(case when auther_type != 'New' then
1 else 0 end) as review,count(*) as total")

in the above query how to write the "case" conditions in ruby query.

You can't - there are no helpers for generating complex select
statements like that.

Fred

To clarify, there aren't any builtin things. There might be a third
party plugin that does this.

Fred