Fix bad SQL in rule checker