0

I've looked a lot on here to see if this has been asked but I couldn't find it. So I'm sorry if it has been answered before.

My question is very basic but for some reason I cannot seem to get it.

I have the following table:

ID    Mike    Carl    Steve    Josh
1     2$      3$      1$       5$
2     4$      5$      1$       2$

So what I need is to know what position out of all ID's does Mike rank from lowest to highest? This would mean for ID 1 it would yield position 2 because he is the second lowest. For ID 2 it would yield position 3 because he is the third lowest. This will go on for about 200000 positions for about 20 people but I just lowered it to simplify it.

Please let me know if you have any ideas and thank you so much in advance for all the help!

MJCS
  • 139
  • 1
  • 11
  • Please use expression rows and columns instead of position to make it more clear – Lithilion Mar 27 '18 at 14:38
  • have a look at "@rownum". refer to https://stackoverflow.com/questions/3614666/mysql-get-row-position-in-order-by/3614741 – cruxi Mar 27 '18 at 14:40
  • @cruxi i'm probably explaining it badly because that Is not what I need. I need to know what position horizontally for each row the user Mike is. So compared to all the other people (columns) where does he rank from lowest to highest. – MJCS Mar 27 '18 at 14:42
  • @MichaelJC do you have to do it in MySQL? can you not take your resultset and order it in your backend? – cruxi Mar 27 '18 at 15:09
  • @cruxi I actually just exported it to excel and just did a rank on each column. Didn't want to have it but it worked :D thank you for the help though – MJCS Mar 27 '18 at 15:15

1 Answers1

0

Just exported to excel and used rank on each column.

MJCS
  • 139
  • 1
  • 11