I have a table structure
ID Col_1 col_2 col_3 col_4 max
1 34 23 45 32 45
2 20 19 67 18 67
3 40 10 76 86 86
I want to derive something like this, the rank column is derived from looking up the "max" column value against columns like "col_1","col_2","col_3","col_4". and it should return me the index or the column number which starts from 1 for col_1 , 2 for col_2 and so on
ID Col_1 col_2 col_3 col_4 max rank
1 34 23 45 32 45 3
2 20 19 67 18 67 3
3 40 10 76 86 86 4
this is what I have tried but unable to get the desired output. any help would be appreciated.
SELECT ID,Col_1,col_2,col_3,col_4,max, match(max) AGAINST(col_1,col_2,col_3,col_4) from demo;