Sensor networks have become ubiquitous and their proliferation in day-to-day life provides new research challenges. Sensors deployed at forest sites, high performance facilities, or areas striken by environmental, or other, phenomena, are only a few representative examples. More recently, mobile sensor networks have made their presence and are rapidly growing in numbers, such as the successful ZebraNet project or PDAs and smartphones. Nevertheless, such networks have mainly been used for data acquisition and data are being processed externally instead of in-network. Basic research problems that arise in the in-network setting include how to adjust in a timely and efficient manner to changing conditions and network topology. In this paper, we present a methodology, based on declarative query processing to alleviate the aforementioned problems, by making the deployment and optimization of a data analysis application as automatic as possible, which also helps execution in mobile environments. Our proposed solution focuses on extending a state-of-the-art sensor network platform, SNEE, with builtin data analysis capabilities.