fix issue with limit and offset when joins are used