On Nov 18, 3:23 pm, Yan Oleg
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> I need to get results from SQL query to database.
>
> I have an SQL statement, e.g.: SELECT MAX(my_field) max_my_field FROM
> my_table WHERE id=5
>
> I want to get the result, what is the max value. I have to get only one
> record with a number, or null if no records found. Please provide Ruby
> code to do this? (to store results in variable)
Checkout the maximum method (http://api.rubyonrails.com/classes/
ActiveRecord/Calculations/ClassMethods.html#M001659)
Fred> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---