[Yandex Cloud documentation](../../index.md) > [Yandex Query](../index.md) > [Working with YQL](index.md) > Data aggregation

# Aggregating data

You can aggregate results by fields.

For example:

* Calculate the number of taxi rides.
* Calculate the average tip size.
* Group by taxi pick-up location (`PULocationID`).

```sql
SELECT
    PULocationID,
    COUNT(*) AS rides_count,    -- The COUNT aggregate function returns the number of rows
                                -- produced by the query.
                                -- The asterisk (*) means that the COUNT function
                                -- will count every row in the table.
                                -- The function counts each separate row,
                                -- including rows containing null values.
    AVG(tip_amount) AS avg_tip_amount
FROM
    `tutorial-analytics`
GROUP BY PULocationID           -- The field that data is grouped by.
```

Check the example in the right-hand section and click ![run](../../_assets/console-icons/play-fill.svg) **Run**.
The query result will appear in the **Result** tab as a table or chart.

#### Useful links {#see-also}

* [SELECT](https://ydb.tech/docs/en//yql/reference/syntax/select).
* [GROUP BY](https://ydb.tech/docs/en//yql/reference/syntax/group_by).
* [Data aggregation function](https://ydb.tech/docs/en//yql/reference/builtins/aggregation).