# Access Frequency Example

The distribution of access frequency. This is useful to see the distribution of user engagement.

* [Access Frequency Query Example for Hive and Trino](/products/customer-data-platform/data-workbench/queries/examples/access-frequency-example#access-frequency-query-example-for-hive-and-presto)
* [Sample Input](/products/customer-data-platform/data-workbench/queries/examples/access-frequency-example#sample-input)
* [Sample Output](/products/customer-data-platform/data-workbench/queries/examples/access-frequency-example#sample-output)


## Access Frequency Query Example for Hive and Trino


```sql
SELECT 
  T.cnt,
  COUNT(1) AS frequency
FROM (
    SELECT 
      user_id,
      COUNT(1) AS cnt
    FROM
      access
    GROUP BY
      user_id
  ) T
GROUP BY
  T.cnt
ORDER BY
  frequency
```

## Sample Input

| **time** | **user_id** |
|  --- | --- |
| 1416435585 | 2 |
| 1416435586 | 3 |
| 1416435587 | 5 |
| 1416435588 | 1 |
| ... | ... |


## Sample Output

| **cnt** | **frequency** |
|  --- | --- |
| 1 | 621 |
| 2 | 121 |
| 3 | 71 |
| 4 | 61 |
| 5 | 41 |
| 6 | 31 |
| 7 | 11 |
| 8 | 3 |
| 9 | 1 |