fixed an issue with sql where and top row count statement