在用laravel执行平均函数时,如何忽略NULL的值。在下面的代码中,它将空值视为零。对不起,我英语不好,希望你能理解我的意思,谢谢。
下面的是我的代码
$average2 =round( $scores->where('student_id',$id)->avg('term2_result'));
发布于 2019-06-21 01:47:49
试一试
$average2 = round($scores->where('student_id', $id)
->where('field_name', '!=', null)
->avg('term2_result'));
https://stackoverflow.com/questions/56695785
复制相似问题