How can i run and get the value from the following sql:
select avg(my_field) from my_table where which_year=‘0506’ and
which_week <= 21 and my_foreign_key_id=10
cheers
How can i run and get the value from the following sql:
select avg(my_field) from my_table where which_year=‘0506’ and
which_week <= 21 and my_foreign_key_id=10
cheers
thanks!
On 1/16/06, chris hulbert [email protected] wrote:
How can i run and get the value from the following sql:
select avg(my_field) from my_table where which_year=‘0506’ and
which_week <= 21 and my_foreign_key_id=10
You can use:
YourModel.connection.select_value(your_query_string)
…which returns the result as a string that you will need to type_cast
into whatever you need.
If you find yourself doing a lot of this, you should look at the cool
Calculations plugin:
http://techno-weenie.net/svn/projects/plugins/calculations/
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs