Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Applies to:
Databricks SQL
Databricks Runtime
Divides the rows for each window partition into n buckets ranging from 1 to at most n.
Syntax
ntile([n])
Arguments
n: An optional INTEGER literal greater than 0.
Returns
An INTEGER.
The default for n is 1. If n is greater than the actual number or rows in the window
You must use the ORDER BY clause with this function.
If the order is non-unique, the result is non-deterministic.
Examples
> SELECT a, b, ntile(2) OVER (PARTITION BY a ORDER BY b) FROM VALUES ('A1', 2), ('A1', 1), ('A2', 3), ('A1', 1) tab(a, b);
A1 1 1
A1 1 1
A1 2 2
A2 3 1