Updated on 2025-08-14 GMT+08:00

Window Functions

This section describes window functions, including their syntax, parameters, and usage examples.

Function List

Table 1 Window functions

Function

Description

ntile

Divides data in a window partition sequentially into n groups.

ntile

This function divides data in a window partition sequentially into n groups.

Syntax:

ntile(n) over (
   [partition by partition_expression]
   [order by order_expression]
 )
Table 2 Parameter description

Parameter

Description

Type

Mandatory

n

Number of groups.

Integer

Yes

partition by partition_expression

Partition expression for dividing data into partitions.

Any

Yes

order by order_expression

Window sorting. An order by clause is used to sort rows in a window partition.

Any

Yes

Return value type: integer

Example: status,host,ntile(5) over (partition by status order by host) as n

Table 3 Query and analysis results

Type

Query Statement

Returned Result

Scenario

status,host,ntile(5) over (partition by status order by host) as n