SQL Cookbook学习笔记-使用数字

计算平均值

select avg(coalesce(sal,0))

from t2

 

COALESCE()会返回组里第一个非空的值,详见P144

你可能感兴趣的:(sql)