I could just use a find_by_sql to accomplish this, but I'd like to do it the Rails way if possible.
My SQL query looks like this:
SELECT regions.id, max(updated_at) FROM demographics
JOIN regions ON (regions.id = demographics.region_id)
JOIN region_stats ON (region_stats.region_id = regions.id)
WHERE region_stats.income_level = 1
GROUP BY demographics.region_id;
Is there a way to convert this cleanly to Rails?
updated_atbelongs to, can you clarify?