I am new to MySQL. I know that ROW_NUMBER() OVER (PARTITION)
will not work in MySQL. I want to convert the code from SQL Server to MySQL:
SELECT *,
ROW_NUMBER() OVER (
Partition By X.TPID,originTLA, destinationTLA
ORDER BY packageStartDate,totalPackageSavingsPct desc
) AS ttl_perct_rnk
FROM TABLE
I want to convert this code to MySQL.
In Most of the cases the requirement to find rank is based on a single column. But here we have to find rank based on three columns. It is easy to find rank based on single column. But I am not sure how can we implement the rank based on three column or multiple columns.
Best Answer
This what you are looking for?:
Or you can upgrade to MySQL 8.0 or MariaDB 10.2 to get CTEs and Windowing functions.