This is the query I get from the above:
```sql
SELECT 
       "student_exercises".* 
FROM   "student_exercises" 
INNER JOIN 
      "student_assignments" ON "student_assignments"."id" = "student_exercises"."student_assignment_id" 
INNER JOIN 
      "students" ON "students"."id" = "student_assignments"."student_id" 
INNER JOIN "users" ON "students"."user_id" = "users"."id" 
WHERE "student_exercises"."assignment_exercise_id" = 10 
ORDER BY "students"."has_dropped", "students"."is_auditing", lower("users"."last_name")
```
This is exactly the query that's needed.  I can understand the avoid handcoded sql argument.   But don't you guys think this scenario (where rails is unable to produce the optimal sql output) - judicious sprinkling of handcoded sql makes for a performant page?