In this paper a data aggregation and dilution scheme is introduced for wireless sensor networks, which can be perceived as a distributed relational database. A new algorithm that can run on tiny sensor nodes to aggregate or dilute the sensed data packets is developed. Two location based hash functions are also introduced to determine how the sensed data can be grouped or which sensors should be excluded from a query. Analytical models are provided for the performance evaluation. The numerical results show that our scheme can reduce the number of transmitted packets 50% on the average comparing to the case where aggregation or dilution is not used.