Saltar al contenido principal
waffle.svg
Domo

Creating a Rank or Row Count

Version 1

 

Important: When referencing this page outside of Knowledge Base, use this link: http://knowledge.domo.com?cid=rank

To create a rank or row count for a DataSet, you can use a MySQL or RedShift DataFlow.

In MySQL

Enter the following input code:

Select

 a.*

,@rank:= @rank + 1 AS `Rank`

FROM your_dataset a
,(SELECT @rank:=0) b

ORDER BY ___


 

In MySQL Windowed

Enter the following input code:

Select

a.*

,@rank:=  IF(@prev = a.`column`,@rank + 1,1) AS `Rank`

,@prev:= a.`column`

FROM your_dataset a
,(SELECT @rank:=0, @prev:=’’) b


In RedShift

Enter the following input code:

ROW_NUMBER () OVER

(

[ PARTITION BY expr_list ]

[ ORDER BY order_list ]

)