0

我通过对引用者进行分组来获取数据,并且在每个引用者中,我尝试获取每个引用者的平均点击次数。例如:

referer a site
--------------
avg clicks: 12


referer b site
--------------
avg clicks: 4

我使用此代码

SELECT *, COUNT(*)
FROM track
GROUP BY referer
ORDER BY id desc
LIMIT 15    

while ($yazdir=mysql_fetch_array($sqlsorgu))
{
    $count = $yazdir['COUNT(*)'];
    $clicks[] = $yazdir[clicks];
    $score_sum = array_sum($clicks);
    $mean_average = $score_sum / $count;
}

但是,它总是计算错误的数字,也许它也存储了以前的数字。获得每个推荐人的平均点击次数的正确方法是什么?

4

1 回答 1

3

为什么不

    SELECT *, COUNT(*),AVG(clicks)  
   FROM track GROUP BY referer ORDER BY id desc limit 15
于 2013-04-28T18:37:29.383 回答