> For the complete documentation index, see [llms.txt](https://couchbase.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://couchbase.shujuwajue.com/n1ql-ji-chu-cao-zuo-jiao-cheng/n1qlji-chu/21having-fen-zu-shu-ju-de-guo-lv.md).

# 21.HAVING 分组数据的过滤

类似于WHERE子句过滤文档,我们可以使用HAVING过滤分组过后的结果。

Query:

```sql
SELECT relation, COUNT(*) AS count
    FROM tutorial
        GROUP BY relation
            HAVING COUNT(*) > 1
```

结果:

```javascript
{
  "results": [
    {
      "count": 2,
      "relation": "friend"
    },
    {
      "count": 2,
      "relation": "cousin"
    }
  ]
}
```
