Query sensor data from db