Fixed having clauses in QueryExecutor

Signed-off-by: Tom Wright <tom@inflatablecookie.com>