fix some bugs in special cases with BIND, UNION, GROUP BY and ORDER BY