Bugs fixed

Add SubSampling for queries.
Fix bug in JoinIndex
Fix bug in PivotTable