SQL 学习笔记
RoadGhost
这个作者很懒,什么都没留下…
展开
-
连接列值
将多列按照一定的格式生成一列返回select ename + ' work as a ' + job as msg from empwhere deptno=10将不同的列按照一定的格式组合成新的一列返回转载 2013-12-05 10:01:22 · 487 阅读 · 0 评论 -
在select 语句中使用条件逻辑
select ename,sal,case when sal<=2000 then 'underpaid' when sal>=4000 then 'overpaid' else 'ok'end as statusfrom emp针对查询的返回值执行条件逻辑,可以给case表达式取别名,else可以忽略,返回null转载 2013-12-05 10:19:40 · 831 阅读 · 0 评论 -
在where语句中引用取别名的列
select * from(select sal as salary, comm as commission from emp) xwhere salary <5000将取别名的查询(x)作为内联视图,便可以再外部查询中引用其中的别名列。该方法在下列情形的where子句中都可以使用:1.聚集函数2.标量子查询3.视窗函数4.别名转载 2013-12-05 09:53:58 · 887 阅读 · 0 评论