为什么这个SUM不仅是最高的5分,而且全部都是分数?

时间:2019-07-19 06:26:09

标签: mysql

这是这个问题的后继内容

How do I sum only the 3 best scores from this query?

我们现在要进入本赛季的舞台,其中一些球员参加了6场比赛,现在我从上述问题中使用的代码应该只汇总了5项最佳成绩,但这只是小提琴。

https://www.db-fiddle.com/f/4ufuFAXKf7mi5yefNQqoXM/19

正在添加所有6个得分,而不仅仅是前5名。

我希望期望的结果看起来像这样:

+--------+--------+--------+--------+--------+--------+--------+-------+
| player | event1 | event2 | event3 | event4 | event5 | event6 | best5 |
+--------+--------+--------+--------+--------+--------+--------+-------+
| 1      | 15     | 8      | 15     | 9      | 8      | 14     | 61    |
| 2      | 5      | 9      | 5      | 12     | 9      | 15     | 50    | 
+--------+--------+--------+--------+--------+--------+--------+-------+

我哪里出错了

2 个答案:

答案 0 :(得分:1)

使用此

a?b:c

Demo

答案 1 :(得分:0)

html_email_template_name