This document proposes an energy efficient three-level model for query optimization in wireless sensor networks (WSNs). At the three levels are: base station, cluster heads, and sensor nodes. The base station maintains metadata about cluster heads and sensor nodes. When a query is received, it first checks if the result is cached. If not, it checks the status of cluster heads and selects a new cluster head if needed. The query is then disseminated to cluster heads using a modified Bellman-Ford algorithm. Cluster heads aggregate data from relevant sensor nodes and send the result to the base station. This model aims to minimize communication costs during query processing in WSNs.