Important
The SingleStore 9.1 release candidate (RC) is available now. It will be promoted to general availability (GA) soon and at that time it will be renamed to SingleStore 10.
In the interim, SingleStore 9.1 RC can be used to preview, evaluate, and provide feedback on the new and upcoming features in SingleStore 10, while SingleStore 9.0 is recommended for production workloads.
DENSE_ RANK
On this page
The DENSE_ function returns the rank of the current row within the partition as specified by the order by clause.
If two or more rows tie they have the same ranking.
The difference between RANK and DENSE_ is that DENSE_ does not skip values after a tie.
Syntax
DENSE_RANK () OVER (
[PARTITION BY (col | expr), ...]
[ORDER BY (col | expr), ...]
)Return Type
Integer
Examples
CREATE TABLE dr_example (a int, b int);INSERT INTO dr_example VALUES(1,2),(2,2),(3,3),(4,3);
SELECT a,b, DENSE_RANK() OVER(ORDER BY b) FROM dr_example;
+------+------+-------------------------------+
| a | b | DENSE_RANK() OVER(ORDER BY b) |
+------+------+-------------------------------+
| 1 | 2 | 1 |
| 2 | 2 | 1 |
| 3 | 3 | 2 |
| 4 | 3 | 2 |
+------+------+-------------------------------+Last modified: