---
schema_version: "1"
id: dc303412ebb631a31ca7af4e4300adb6418723ff87993e4264498d27dcb0ff3b
title: count()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_saql/guides/concept/bi-saql-fn-agg-cnt.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-fn-agg-cnt.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: e0b85e931d66f33ec5198f4df0bee62aa0edc98609ae2afe8f593732932bac0f
products:
  - Analytics SAQL Developer Guide
  - analytics
---

# count()

Returns the number of rows that match the query criteria.

For example, to calculate the number of carriers:

```nolang
q = foreach q generate 'carrier' as 'carrier', count() as 'count';
```

`count()` operates on the stream that is input to the `group` or `cogroup` statement. It doesn’t operate on the newly grouped stream or on an ungrouped stream.

```nolang
q = load "Carriers";
q = group q by (Year);
q = foreach a1 generate count(q) as countYear, count() as count, Year as year;
```
