creates a query for aging analysis