0

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.

1 Answer 1

2

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")
Sign up to request clarification or add additional context in comments.

4 Comments

Thank you very much!! Just been having problems with ActiveRecord, sigh ahah, but thank you again
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 api.rubyonrails.org but you have to really know what you are looking for.
Oh, and be sure to mark the question as "accepted" for future searchers. And welcome to Stack Overflow!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.