とクエリのランキングリストを選択:MySQLは私がランキングリストを作成するには、次のクエリを使用しています条件
SELECT Count(a2.performance) rank,
a1.performance,
a1.wind,
a1.name,
a1.surname,
a1.dob,
a1.prov,
a1.pos,
a1.place,
a1.date
FROM men a1,
men a2
WHERE a1.performance > a2.performance
OR (a1.performance = a2.performance
AND a1.name = a2.name
AND a1.surname = a2.surname
AND a1.wind = a2.wind
AND a1.dob = a2.dob
AND a1.prov = a2.prov
AND a1.pos = a2.pos
AND a1.place = a2.place
AND a1.date = a2.date
AND a1.event = '100m'
AND a1.year = '2016')
GROUP BY a1.name,
a1.surname,
a1.performance
ORDER BY `a1`.`performance` ASC
私のテーブルには、次のようになります。
| id | event | performance | wind | name | surname | dob | prov | pos | place | date | year |
マイランキングのリストは完璧に動作しますが、I出力の一部ではないevent
とyear
フィールドに条件を追加することもできます。私がyear
とevent
の条件を持っている場合、何もしません。誰かが手伝ってくれそうな人は、フィールドでそれらをフィルタリングしてください。これは私が取得していますものです
|id|event|performance|wind|name|surname|dob|prov|pos|place|date|year|
---------------------------------------------------------------------
| 1|100m | 10.00 |2.0 |John| Coe | | | | | |2016|
| 2|100m | 10.01 |2.0 |John| Smith | | | | | |2017|
| 3|200m | 20.10 |2.0 | U | Bolt | | | | | |2016|
| 4|100m | 10.05 |2.0 |Pete| Doe | | | | | |2016|
:
これは、テーブルのように見えるものである
|rank|performance|wind|name|surname|dob|prov|pos|place|date|
| 1 | 10.00 |2.0 |John| Coe | | | | | |
| 2 | 10.01 |2.0 |John| Smith | | | | | |
| 3 | 10.05 |2.0 |Pete| Doe | | | | | |
| 4 | 20.10 |2.0 | U | Bolt | | | | | |
この条件は、イベント= 100メートルとイベントです私が欲しいものである= 2016とそれは出力されるすべての順位をつけます。
|rank|performance|wind|name|surname|dob|prov|pos|place|date|
| 1 | 10.00 |2.0 |John| Coe | | | | | |
| 2 | 10.05 |2.0 |Pete| Doe | | | | | |
質問イマイチ明確な –
を? –
どのデータ型が年ですか? – scaisEdge