1 or null 反null
0 or null 反null
0 and null 反0
1 and null 反null
0 and 1 反0
null and null 反null
空值替换:
ifnull函数
select *,sal+ifnull(comm,0) 实发工资 from emp;
case when ...then... else ... end逻辑表达式
select ename,sal,case when sal>=3000 then \'高\' when sal>=1500 then \'中\' else \'低\' end 工资级别
from emp;
开窗函数 是聚合函数 但是有几条记录返回几条记录。
开窗函数名([<字段名>]) over([partition by <分组字段>] [order by <排序字段> [desc]] [< 滑动窗口>])
over中没有指定分区,排序和滑动窗口,默认表中所有记录为一个区,计算的是分区内所有行。
over中指定分区,没指定排序和滑动窗口,默认计算的分区内的所有行。
over中指定分区,排序,没指定滑动窗口,默认计算分区内第一行到当前行。
over中指定分区,排序,滑动窗口,默认计算分区内滑动窗口范围内的行
row_number() 无参函数