id one two thr fou five
1 37 84 1 68 10
2 72 50 87 41 67
3 66 30 89 57 48
4 29 27 35 75 36
5 2 72 9 1 55
6 33 89 17 40 64
7 70 90 63 26 54
8 36 19 51 43 61
9 10 61 20 44 84
10 2 41 43 65 87
我需要反轉計數上表中的每個數字。在mySQL中的反向計數
例子:
61=>1 because if you count from the bottom to the first 61 there's 1 row
26=>3 because if you count from the bottom to the first 26 there are 3 rows
9=>5 because if you count from the bottom to the first 9 there are 5 rows
and so on...
查詢應輸出類似於所有數字如下表:
Number Rows count
61 1
26 3
9 5
這裏的問題是:如何扭轉計數的MySQL?有特殊功能嗎? 謝謝
如何表有序?通過'ID'?如果是這樣,是否確保'id'是連續的(即沒有間隙)? – eggyal
你有什麼嘗試嗎? –
@eggyal ID不是連續的 - juergend我沒有嘗試任何東西,因爲我不知道如何從底部計算行... – Floppy88