r937 from Sitepoint was kind enough to help me figure out the query I need to return correct results from my database. What I need is to be able to use this query as a scope and to be able to chain other scopes onto this one. The query is: SELECT coasters.* FROM ( SELECT order_ridden, MAX(version) AS max_version FROM coasters GROUP BY order_ridden ) AS m INNER JOIN coasters ON coasters.order_ridde
![Find_by_sql as a Rails scope](https://cdn-ak-scissors.b.st-hatena.com/image/square/98d6f053a97a87156775f60757c60865d0f2c47d/height=288;version=1;width=512/https%3A%2F%2Fcdn.sstatic.net%2FSites%2Fstackoverflow%2FImg%2Fapple-touch-icon%402.png%3Fv%3D73d79a89bded)