write query to data