私はこのテーブルを持っています:拡張
+--------+-----+-----+-----+-----+- -+-----+-----+
| 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 |
| .... | .... | .. | .. | .. | .. | .. | .. | .. |
+--------+-------+-----+-----+-----+-----+----+-----+-----+
TOTALで注文。この合計は、ベスト オブ 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