结果显示最高金额

时间:2013-05-30 08:47:43

标签: sum max

也许有人可以帮助我。

我有5张桌子,我可以从中获得每张桌子的总和,并显示最高金额。

我试过这个,但是我收到了一个错误。

$best_browser_query = mysql_query("select max(sum(google_browser_ie), sum(google_browser_sa), sum(google_browser_ch), sum(google_browser_ff), sum(google_browser_an)) as sum_amount from site_google_browsers limit 1");
while ($best_browser = mysql_fetch_array($best_browser_query)) {
echo '<tr>' .
'  <td class="adm_box_text2">' . TEXT_BEST_BROWSER . '</td>' .
'  <td class="adm_box_text2">' . $best_browser['sum_amount'] . '</td>' .
'</tr>';
}

有谁知道我做错了什么?

1 个答案:

答案 0 :(得分:0)

您不能在列上使用max,您可以尝试以下查询:

select max (sum_amount) from
(select sum(google_browser_ie) as sum_amount union
        sum(google_browser_sa)union
        sum(google_browser_ch) union
        sum(google_browser_ff) union
        sum(google_browser_an)from site_google_browsers limit 1") a;