fix the `having` clause