adding min and max query