PERCENT_RANK

PERCENT_RANK returns the percentage ranking of a value in a group of values. The result is (R - 1) / (N - 1) where R is the rank of the row, and N is the total number of rows in the partition.

No Parameters

Returns: decimal

Example

query:

SELECT account, order_value, PERCENT_RANK() OVER ( PARTITION BY account ORDER BY order_value desc)
  FROM jun_2017_orders

result:

account order_value percent_rank
Betasoloin 5182 0.0
Betasoloin 5100 0.25
Betasoloin 4492 0.5
Betasoloin 2887 0.75
Betasoloin 1036 1.0
Gekko & Co 5622 0.0
Gekko & Co 5304 0.1666
Gekko & Co 5031 0.3333
Gekko & Co 1075 0.5
Gekko & Co 1062 0.6666
Gekko & Co 497 0.8333
Gekko & Co 67 1.0
Plexzap 24949 0.0