# COUNT

The COUNT function returns the total number of input values.

## Syntax

`COUNT(field)`

### Parameters

#### field

This is an expression that outputs values to be counted. If it's omitted, it's equivalent to `COUNT(*)`, which counts the number of rows.

## Examples

Count the number of specific field values:

```esql
FROM employees
| STATS COUNT(height)
```

Count the number of rows using `COUNT()` or `COUNT(*)`:

```esql
FROM employees
| STATS count = COUNT(*) BY languages
| SORT languages DESC
```

The expression can use inline functions. In this example, a string is split into multiple values using the `SPLIT` function, and the values are counted:

```esql
ROW words="foo;bar;baz;qux;quux;foo"
| STATS word_count = COUNT(SPLIT(words, ";"))
```

To count the number of times an expression returns `TRUE`, use a `WHERE` command to remove rows that shouldn’t be included:

```esql
ROW n=1
| WHERE n < 0
| STATS COUNT(n)
```

To count the same stream of data based on two different expressions, use the pattern `COUNT(<expression> OR NULL)`:

```esql
ROW n=1
| STATS COUNT(n > 0 OR NULL), COUNT(n < 0 OR NULL)
```