Skip to main content
NTILE

Assigns a bucket number to each row in a partition

Updated over 2 weeks ago

Description

The NTILE() function assigns a bucket number to each row in a partition, based on the number of buckets configured. This is useful for data segmentation and ranking.

Syntax

NTILE(number)

Output

integer

Variables

  1. number: the number of buckets

Example

NTILE(3) Over (Partition by Group Sort by ID)

ID

Group

Value

NTILE

1

A

10

1

2

A

20

2

3

A

15

3

4

B

30

1

5

B

40

3

Did this answer your question?