我有这张桌子:扩展
+--------+-----+-----+-----+-----+- -+-----+-----+
| Name | T1 | T2 | T1 | T3 | .. | T19 | T20 |
+--------+-----+-----+-----+-----+- -+-----+-----+
| john | 5 | 10 | 50 | 10 | .. | 20 | 8 |
| bill | 2 | 8 | 11 | 5 | .. | 9 | 55 |
| james | 30 | 15 | 12 | 40 | .. | 13 | 10 |
| elsie | 28 | 35 | 20 | 32 | .. | 18 | 1 |
| .... | .. | .. | .. | .. | .. | .. | .. |
+--------+-----+-----+-----+-----+- -+-----+-----+
我想退回这个:
+--------+-------+-----+-----+-----+-----+- -+-----+-----+
| Name | TOTAL | T1 | T2 | T1 | T3 | .. | T19 | T20 |
+--------+-------+-----+-----+-----+-----+- -+-----+-----+
| bill | 250 | 2 | 8 | 11 | 5 | .. | 9 | 55 |
| john | 230 | 5 | 10 | 50 | 10 | .. | 20 | 8 |
| elsie | 158 | 28 | 35 | 20 | 32 | .. | 18 | 1 |
| james | 129 | 30 | 15 | 12 | 40 | .. | 13 | 10 |
| .... | .... | .. | .. | .. | .. | .. | .. | .. |
+--------+-------+-----+-----+-----+-----+----+-----+-----+
按总计排序。这个总数是最好的 15 个 Tx 的总和......
我现在不知道如何做到这一点。
该表来自另一个包含大量数据的表的请求( CREATE VIEW )。
你能帮助我吗 ?
在这一点上,我做了所有 Tx 的总和,但这不是我想要的......
SELECT `Name`, (T1+T2+ T3+T4+T5+T6+T7+T8+T9+T10+T11+T12+T13+T14+T15+T16+T17+T18+T19+T20) AS TOTAL, T1,T2, T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20
FROM `extended`
ORDER BY TOTAL DESC