重新組織的標題:使用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>