complex query, setup queries and time based queries
more work on complex query for agent & activity