我制作了一张桌子,我想用desc命令制作桌子,
示例:取Bank_Account + HandMoney = SUM,并通过Desc描述其总和
我只用#34; HandMoney"并且它运作良好,但我真的不知道如何使两列的总和
编码我现在拥有的东西:
$query = $connection -> prepare("SELECT `p_name`, `HandMoney` FROM `users` ORDER BY `HandMoney` DESC LIMIT 15");
if($query -> execute())
{
if($query -> rowCount())
{
$count = 0;
?>
<thead>
<table class="table-fill2">
<tbody class="table-hover">
<tr>
<th class="text-left">
Postion
</th>
<th class="text-left">
Player Name
</th>
<th class="text-left">
Money
</th>
</tr>
</thead>
<tbody class="table-hover">
<?php
while($query_result = $query -> fetch())
{
?>
<tr>
<td style = "text-left">
<?php
echo ++ $count;
?>
</td>
<td style = "text-left">
<?php
echo $query_result['p_name'];
?>
</td>
<td style = "text-left">
<?php
echo number_format($query_result['HandMoney']);
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
else
{
echo 'No players were found.';
}
}
?>
所以我想要两列(HandMoney + BankMoney = SUM)并按该总和订购玩家
答案 0 :(得分:0)
如果我理解正确,你想拥有它:
SELECT `p_name`, SUM(Bank_Account + HandMoney) as BandH
FROM `users`
GROUP BY p_name
ORDER BY BandH DESC