我使用以下查询创建排名列表:
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 |
我的排名列表完美无缺,但我还想为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 | | | | | |
这就是我想要的条件是event = 100m和event = 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 | | | | | |
答案 0 :(得分:0)
尝试使用' like'而不是' ='
另外,我会仔细检查' OR' ...的语法如果a1.performance>它看起来像是否会被忽略。 a2.performance
答案 1 :(得分:0)
我发现了这一点并对其进行了调整,并且可以解决问题:
<style>
.s4-wpcell-plain{
text-align: -webkit-center !important;
}
</style>
<table style="width:100%" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td id="MSOZoneCell_WebPartWPQ2" valign="top" class="s4-wpcell-plain">
<!-- content -->
</td>
</tr>
</tbody>
</table>