Add query for query history