implement query with where condition