我有這個表:「等級」與下面列: 'student_id數據「分數」發現平均
叫「student_id數據」我使用
<?php echo $myData['student_id'];?>
到所說的「得分」我使用
<?php echo $myData['score'];?>
時,我想打電話給列的平均「得分」我使用
$query="Select AVG(score) as average FROM grade";
$result_array=mysql_query($query);
$average= mysql_fetch_array($result_array);
問題是,在score
列中有一個null
數據,平均值計算爲0
。
所以這裏是列得分拍攝的示例數據: 問題:
'10', '10', '10', '' , '10' will give average of 8.
我想是這樣的:
'10', '10', '10', '' , '10' will give average of 10
任何幫助,如何解決這一問題?
你剛剛嘗試添加'where'標準嗎? '得分不是零'?或者如果它確實是空白的,那麼'where score!='''...... – sgeddes
謝謝......它適用於得分!='' – gtviga