There is no ranking functionality in MySQL. The closest you can get is to use a variable:
SELECT t.*,
@rownum := @rownum + 1 AS rank
FROM YOUR_TABLE t,
(SELECT @rownum := 0) r
so how would that work in my case? I'd need two variables, one for each of col1 and col2? Col2 would need resetting somehow when col1 changed..?
Yes. If it were Oracle, you could use the LEAD function to peak at the next value. Thankfully, Quassnoi covers the logic for what you need to implement in MySQL.
Center one and right/left align other flexbox element
How to store objects in HTML5 localStorage/sessionStorage
How do I modify the URL without reloading the page?
Why doesnt percentage height work in HTML/CSS?
How can I validate an email address in JavaScript?
How can I vertically center a div element for all browsers using CSS?
How can I horizontally center an element?
Get top n records for each group of grouped results
Connect Java to a MySQL database
Syntax error due to using a reserved word as a table or column name in MySQL