# COUNT

The COUNT function returns the total number of input values. If no field is specified, it counts the number of rows.

## Syntax

`COUNT(field)`

### Parameters

#### field

Expression that outputs values to be counted. If omitted, COUNT returns the number of rows, equivalent to `COUNT(*)`.

## Examples

Counts the number of non-null values in the `height` field from the `employees` data.

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

Counts the total number of rows for each language in the `employees` data, sorting the results by language in descending order.

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

Counts the number of elements produced by splitting the `words` string on the semicolon character.

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

Counts the number of times the value of `n` is less than 0 by filtering with `WHERE`.

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

Counts the number of times `n` is greater than 0 and less than 0, respectively, by evaluating two different expressions in the same data stream.

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