Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Need to get average of specific fields in MySQL
jackster the jackle
8/15/2008 3:34:00 PM
Hi Forum,
My Active Record query works fine and pull all records where
ipadd='10.1.1.1' and print out the current_connection_count values but I
need to get the average of those numbers.
here is my Active Record config:
------------------
class Pix
end
device = Pix.find(:all, :conditions => "pixes.ipadd = '10.1.1.1'")
device.each do |line|
puts line.current_connection_count
end
------------------
Is it best to somehow change my sql query to get the average of these
numbers or is it better to try do it after the sql query (which I don't
know how to do either :-)) ?
any help would be appreciated.
thanks
jackster
--
Posted via
http://www.ruby-...
.
1 Answer
Phlip
8/15/2008 3:42:00 PM
0
jackster the jackle wrote:
> device = Pix.find(:all, :conditions => "pixes.ipadd = '10.1.1.1'")
> device.each do |line|
> puts line.current_connection_count
> end
According to the very first cite at...
http://www.google.com/search?q=activereco...
....it should be:
average = Pix.average(:current_connection_count,
:conditions => "ipadd = '10.1.1.1'")
Please consider
http://groups.google.com/group/rubyonr...
for RoR
questions. This group is for old-timers who missed the RoR boat, and questions
about it make us cranky here. (-:
--
Phlip
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Need to get average of specific fields in MySQL
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password