initial implementation of sql query
added sql query building
added timestamp conditions to sql query
added span view sql