Optimizing Network-Side Queries with Timestamp-Join in Wireless Sensor Networks