1、with rollup 可以实现在分组统计数据基础上再进行相同的统计
SELECT name, SUM(score) as score_count FROM score GROUP BY name with rollup
2、 coalesce 来设置一个可以取代NUll 的名称
语法:select coalesce(a,b,c)
参数说明:如果a==null,则选择b;如果b==null,则选择c;如果a!=null,则选择a;如果a b c 都为null ,则返回为null(没意义)
SELECT coalesce(name, ‘汇总‘), SUM(score) as score_count FROM score GROUP BY name with rollup
3、MYSQL连接使用
4、NULL 值处理
select name from user where 1=1 and customer_name IS NULL
select name from user where 1=1 and customer_name IS NOT NULL
原文:https://www.cnblogs.com/wueryuan/p/11792535.html