特牛网址导航

sql多列求平均值-CSDN博客

网友收藏
文章浏览阅读4.2k次。mysqlSELECT *,CASE WHEN SUM(IFNULL(emp_no_new,0)+IFNULL(emp_no_new_1,0)) =0 THEN 0 ELSE SUM(IFNULL(emp_no_new,0)+IFNULL(emp_no_new_1,0))/ SUM(IF(emp_no_new IS NULL,0,1)+IF(emp_no_new_1 IS NULL,0,1)) END AS avg FROM dept_emp GROUP BY emp_nooracle_sql多列求平均