关于SQL Server查询语句的使用
一.查询第二个字母是t或者a的雇员的全部信息 代码如下:select *from employees where firstname like '_[t,a]%' 注意:在sql中%表示字符串,所以不可像matlab一样用其注释,两个双斜线好像也不行,/**/可以,有网友说sql单行注释为-- 二.更改字段名 代码如下:select '名字' = firstname,'姓氏' = lastnamefrom employees where firstname like '_[t,a]%' 或者 代码如下:select firstname as '名字',lastname as '姓氏' from employees where firstname like '_[t,a]%' 三.top关键字 代码如下:/*检索出符合条件的前70%条记录*/select top 70 percent firstname as '名字',a]%'1 /*检索出符合条件的前2条记录*/ select top 2 firstname as '名字',a]%' 四.union关键字注意:标准sql只提供了并操作,未提供交(intersection)和差(minus)操作。代码如下:select * from employees where title = 'Sales Manager' union select * from employees where address is not null 显示: 服务器: 消息 8163,级别 16,状态 4,行 1 五.compute关键字compute子句需要以下信息:
注意:order by是必须的,并且 compute by后的参数应该在order by后的参数中出现过
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |