搬山行者

无志愁压头,有志能搬山

业余程序员的学习笔记~


Sql经典实例 第一章

目录

串联多列的值

select ename || ' works as a ' ||  job as msg 
  from emp 
  where deptno=10

在SELECT语句里使用条件逻辑

select ename, sal,
    case when sal <= 2000 then 'UNDERPAID'
        when sal >= 4000 then 'OVERPAID'
        else 'OK'
    end as status
from emp

限定返回行数

select * from emp limit 5

随机返回若干行记录

select ename, job from emp order by random() limit 5

查找null值

select * from emp where comm is null

把null值转换为实际值

select coalesce(comm, 0) from emp