# QBCountAggregate

## Overview

The `QBCountAggregate` class represents aggregate expressions, such as `count`, `min`, and `max`, within a `QBSelect` query. It provides a range of methods and properties for constructing and manipulating aggregate expressions, allowing for customization of query results and conditions.

Aggregates can be used to calculate summaries, apply mathematical functions, or manipulate data within a query. Properties like `count`, `sum`, and `avg` allow direct creation of aggregate expressions, while others like `abs` or `round` perform mathematical operations. Sorting and conditional operations can also be applied using properties such as `asc`, `desc`, and `isNull`.

Methods extend the functionality of aggregates by enabling operations like comparison (`eq`, `between`, `like`), mathematical manipulation (`plus`, `minus`, `mod`), and substring extraction (`substring`). These features provide fine-grained control over how aggregate data is computed and retrieved.

The `QBCountAggregate` class integrates with query builder constructs like [QBColumn](https://docs.servoy.com/reference/servoycore/dev-api/database-manager/qbcolumn), [QBCondition](https://docs.servoy.com/reference/servoycore/dev-api/database-manager/qbcondition), and [QBSort](https://docs.servoy.com/reference/servoycore/dev-api/database-manager/qbsort), enabling complex query logic and data transformations.

## **Extends**

[QBIntegerColumn](/reference/servoycore/dev-api/database-manager/qbintegercolumn.md)

## Properties Summarized

| Type                                                                                 | Name                  | Summary                                   |
| ------------------------------------------------------------------------------------ | --------------------- | ----------------------------------------- |
| [QBIntegerColumn](/reference/servoycore/dev-api/database-manager/qbintegercolumn.md) | [distinct](#distinct) | Add a distinct qualifier to the aggregate |

## Properties Detailed

### distinct

Add a distinct qualifier to the aggregate

**Type**\
[QBIntegerColumn](/reference/servoycore/dev-api/database-manager/qbintegercolumn.md)

**Sample**

```js
// count the number of countries that we ship orders to
var query = datasources.db.example_data.orders.createSelect();
query.result.add(query.columns.shipcountry.count.distinct);
```

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.servoy.com/reference/servoycore/dev-api/database-manager/qbcountaggregate.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
