> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8c05c8a2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> QUALIFY 子句文档

# QUALIFY 子句

允许对窗口函数的结果进行过滤。它与 [WHERE](/zh/reference/statements/select/where) 子句类似，但不同之处在于：`WHERE` 在窗口函数计算之前执行，而 `QUALIFY` 在其后执行。

在 `QUALIFY` 子句中，可以通过别名引用 `SELECT` 子句里的窗口函数结果。或者，`QUALIFY` 子句也可以基于未在查询结果中返回的其他窗口函数结果进行过滤。

<div id="limitations">
  ## 限制
</div>

如果没有需要计算的窗口函数，就不能使用 `QUALIFY`。请改用 `WHERE`。

<div id="examples">
  ## 示例
</div>

示例：

```sql theme={null}
SELECT number, COUNT() OVER (PARTITION BY number % 3) AS partition_count
FROM numbers(10)
QUALIFY partition_count = 4
ORDER BY number;
```

```text theme={null}
┌─number─┬─partition_count─┐
│      0 │               4 │
│      3 │               4 │
│      6 │               4 │
│      9 │               4 │
└────────┴─────────────────┘
```
