Skip to content
Advertisement

Not able to understand how to impose row_num() without using it through naive sql approach whereas rank and dense_rank works

I have below data set:

mysql> select * from covid_test order by Country, Confirmed;

Below queries for rank and dense_rank is working fine however I am not able to get query for row_num, all my strategy fails:

How to achieve row_num for he same set?

Advertisement

Answer

You must also check the condition ct1.Confirmed = ct.Confirmed, in which case you must count the rows with ct1.SNO < ct.SNO:

See the demo.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement