Forum: Ruby on Rails complex sql query approach

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Sean O'Hara (Guest)
on 2007-01-19 17:32
(Received via mailing list)
Hi All,

I have a question about what would be the best or the "rails" way to
generate a report from my web app that is basically a web store. I
wonder if
I should just come up with a complex sql query by hand (which would
take a while to figure out since I don't know much beyond basic sql,
haven't delved into joins yet). Or should I just use my rails models and
attributes and do all the calculations in ruby (I fear this could this
entail a significant database hit).

Here is my data structure.

Artists has_many Releases has_many Products has_many LineItems has_many

I would like to generate a sales report that lists each artist with
associated releases and for each product associated with that release I
would like to list the number of copies sold and the total sales price.

Any opinions on the best way to approach this?

Thanks in advance,
Craig W. (Guest)
on 2007-09-26 00:40
(Received via mailing list)
On Thu, 2007-01-11 at 19:39 -0500, Sean O'Hara wrote:
> Any opinions on the best way to approach this?
the find (complex searches)...

the view code - start hacking

This topic is locked and can not be replied to.