Fixed applyLimit for 'SELECT DISTINCT'