Fix SQL error with duplicate limit statement