I fixed the issue in 2.7.1 by replacing query.php file in wp-includes with the query.php file from an older version of wordpress ie 2.6.5.
Looks like there is a bug in the latest version.
How do I fix this problem ? please be specific as the previous fix by Flowdrops is not possible anymore.