query function for customer and subscriber