working on query for sqlite