# Iterate Through Rows of a Query

The latest set of rows will be populated in the $Databases<DatabaseName>.<TableName>.<QueryName>.QueryResults tag each time that a Query is executed via one of the following:

- An automatic update from an element on a Page;
- Manually executing the $Databases.<DatabaseName>.<TableName>.<QueryName>.Run() command;

- The Update Query on Parameter Changed parameter is enabled.

  Note: See the Advanced Query Options topic for more information.

This will enable you to iterate through the rows, and perform whatever type of processing you need to utilize. However, keep in mind the following:

- You need to cast the row's value using the correct data type.

- Using an integer lookup instead of a string may improve performance. For example:

      double sum = 0;
      foreach (DataRow row in $Databases.FastDatabase.Results.GetRecent.QueryResults)
          sum += Convert.ToDouble(row["Confidence"]);