Scoped GlideAggregate - addQuery(String name, String operator, String value)

Adds a query to the aggregate.

Table 1. Parameters
Name Type Description
name String The query to add.
operator String The operator for the query.
value String The list of values to include in the query.
Table 2. Returns
Type Description
GlideQueryCondition The query condition.
//Number of incidents varies depending on the current state
//of the incident table
var count = new GlideAggregate('incident');
count.addQuery('active', '=','true');
count.addAggregate('COUNT', 'category');
count.query();  
while (count.next()) {
   var category = count.category;
   var categoryCount = count.getAggregate('COUNT', 'category');
   gs.info("There are currently " + categoryCount + " incidents with a category of " + category);
}
Output:
There are currently 1 incidents with a category of database
There are currently 5 incidents with a category of hardware
There are currently 42 incidents with a category of inquiry
There are currently 4 incidents with a category of network
There are currently 4 incidents with a category of request
There are currently 7 incidents with a category of software