富贵资源网 Design By www.hznty.com
复制代码 代码如下:
--执行顺序 From Where Select
select * from
(select sal as salary,comm as commission from emp ) x where salary<5000
--得出 Name Work as a Job
select ename +' Work as a'+job as msg from emp where deptno=10
--如果员工工资小于2000返回UnderPaid 大于等于4k 返回OverPaid 之间返回OK
select ename,sal,
case when sal<2000 then 'UnderPaid'
when sal>=4000 then 'OverPaid'
else
'OK'
end
from emp
--从表中随机返回N条记录 newid()
--order by 字句中指定数字常量时,是要求根据select列表中相应位置的列排序
--order by 字句中用函数时,则按函数在没一行计算结果排序
select top 5 ename from emp order by newid()
--找空值is null
select * from emp where comm is null
--将空值转换为实际值
--解释:返回其参数中第一个非空表达式
--coalesce 联合,合并,结合.英音:[,k"" src="/UploadFiles/2021-04-09/20111025145933625.png">
--执行顺序 From Where Select
select * from
(select sal as salary,comm as commission from emp ) x where salary<5000
--得出 Name Work as a Job
select ename +' Work as a'+job as msg from emp where deptno=10
--如果员工工资小于2000返回UnderPaid 大于等于4k 返回OverPaid 之间返回OK
select ename,sal,
case when sal<2000 then 'UnderPaid'
when sal>=4000 then 'OverPaid'
else
'OK'
end
from emp
--从表中随机返回N条记录 newid()
--order by 字句中指定数字常量时,是要求根据select列表中相应位置的列排序
--order by 字句中用函数时,则按函数在没一行计算结果排序
select top 5 ename from emp order by newid()
--找空值is null
select * from emp where comm is null
--将空值转换为实际值
--解释:返回其参数中第一个非空表达式
--coalesce 联合,合并,结合.英音:[,k"" src="/UploadFiles/2021-04-09/20111025145933625.png">
富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com
暂无评论...