views:

28

answers:

1

Hello,

I'm having problems with getting a value from a single column call.

select sum(price) as testPrice from sales where quantity > 10

but when I inspect the resultset, I get the following,

[#"5"}>]

Any help is appreciated, thank you.

+2  A: 

That is a very strange result. I am curious why you are not writing the query using ActiveRecord methods:

@testPrice = Sale.sum(:price, :conditions => "quantity > 10")
Doug Neiner
Thank you very much!! Just been having problems with ActiveRecord, sigh ahah, but thank you again
Hey, no worries. So did this fix your problem?
Doug Neiner
yeah, it did. Is there any good API you know about, something like noobkit.com(that used to work)
Not that I have found. I just use http://api.rubyonrails.org but you have to really know what you are looking for.
Doug Neiner
Oh, and be sure to mark the question as "accepted" for future searchers. And welcome to Stack Overflow!
Doug Neiner