重新组织的标题:使用MySQL的Group By和Sum计算其他列的总值
<p>我有两列,如下所示:</p>
<table class="s-table">
<thead>
<tr>
<th>字</th>
<th>金额</th>
</tr>
</thead>
<tbody>
<tr>
<td>狗</td>
<td>1</td>
</tr>
<tr>
<td>狗</td>
<td>5</td>
</tr>
<tr>
<td>大象</td>
<td>2</td>
</tr>
</tbody>
</table>
<p>我想对金额进行求和,得到结果</p>
<table class="s-table">
<thead>
<tr>
<th>字</th>
<th>金额</th>
</tr>
</thead>
<tbody>
<tr>
<td>狗</td>
<td>6</td>
</tr>
<tr>
<td>大象</td>
<td>2</td>
</tr>
</tbody>
</table>
<p>到目前为止我尝试过(但失败了)的是:</p>
<pre class="brush:php;toolbar:false;">SELECT word, SUM(amount) FROM `Data` GROUP BY 'word'</pre>
<p><br /></p>