Big fan of raw sql, but practically speaking (as it relates to developing with rails) CTEs can be rewritten as subqueries, the advantage being that they are linear instead of nested in SQL.
With AR queries you can do the same and make it linear in ruby (and then the computer doesn't really care if your sql is nested)
With AR queries you can do the same and make it linear in ruby (and then the computer doesn't really care if your sql is nested)