sql-rank

Determine Rank based on Multiple Columns in MySQL

旧巷老猫 提交于 2019-12-17 05:12:48
问题 I have a table which has 3 fields, I want to rank column based on user_id and game_id. Here is SQL Fiddle : http://sqlfiddle.com/#!9/883e9d/1 the table already I have : user_id | game_id | game_detial_sum | --------|---------|--------------------| 6 | 10 | 1000 | 6 | 11 | 260 | 7 | 10 | 1200 | 7 | 11 | 500 | 7 | 12 | 360 | 7 | 13 | 50 | expected output : user_id | game_id | game_detial_sum | user_game_rank | --------|---------|--------------------|------------------| 6 | 10 | 1000 | 1 | 6 |

Determine Rank based on Multiple Columns in MySQL

流过昼夜 提交于 2019-12-17 05:12:45
问题 I have a table which has 3 fields, I want to rank column based on user_id and game_id. Here is SQL Fiddle : http://sqlfiddle.com/#!9/883e9d/1 the table already I have : user_id | game_id | game_detial_sum | --------|---------|--------------------| 6 | 10 | 1000 | 6 | 11 | 260 | 7 | 10 | 1200 | 7 | 11 | 500 | 7 | 12 | 360 | 7 | 13 | 50 | expected output : user_id | game_id | game_detial_sum | user_game_rank | --------|---------|--------------------|------------------| 6 | 10 | 1000 | 1 | 6 |