Hello there,
I have following SQL query:
SELECT name, (SELECT MAX(price)
FROM products as b
WHERE a.name = b.name),
(SELECT MIN(price)
FROM products as b
WHERE b.name = a.name)
FROM products
GROUP BY name
And I would like to ask you, how to write the query above in Rails
notation… I am new in RoR and I have no idea how to write this
complicated query…
My currently query looks this:
Product.find(:all,
:per_page => 20, :page => page,
:group => “name”,
:order => name)
And I would like the query above rewrite to the shaped as
“Product.find…”… could anyone help me please with this problem?
Thank you,
Manny