Remove offset from cloned queries used in subquery loads.

Having an offset in a subquery causes SQL errors in MySQL. Also include a test to ensure HAVING is not an issue.

Fixes #4465