我有如下表:正確使用MySQL的總和功能
Field | Type | Null | Key | Default | Extra |
+-----------------+----------------------+------+-----+---------+-------+
| SMILES | char(200) | NO | PRI | | |
| ConfRank | smallint(5) unsigned | NO | | NULL | |
| CompTime | double | YES | | NULL | |
我想要得到一個特定的SMILES(意COMPTIME添加特定的笑容人confrank)總COMPTIME。
我試過如下:
SELECT SMILES,(SUM(CompTime)) From GeoAndEnergies GROUP BY ConfRank WHERE SMILES='C';
而且收到此錯誤:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
WHERE SMILES='C'
' at line 1
我也試過:
SELECT SMILES,(SUM(CompTime)) From GeoAndEnergies GROUP BY ConfRank WHERE SMILES='C' GROUPBY ConfRank ;
並得到了另一個錯誤:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
WHERE SMILES='C' GROUPBY ConfRank
' at line 1
什麼是正確的語法?
完美,謝謝! – Laetis
其中是您的表格中的方法字段 –