SQL_Study

SQL 关键字:

1,CAST:

SELECT CAST(productID as varchar(30)+':'+productName) as Name

from Prouduct --把 int 转为 varchar 类型去处理. (相当于string.Formate()方法. )

2, CASE:

SELECT studentName,

case Score

  when Score<60 then '不及格'

  when Score>90 then '良'

  else  '优'

end

from StudentScore --CASE: 对某个字段分出等级.

3, INTO:

into的作用: (1),创建新表,(2),把select 得到的数据插入新表中. (note:必须要有 create table的权限.)

eg:

select *

into newtable

from UserInfo

4,UNION:

用UNION 查询,则会去除重复的行, 而如果用All ,则不会.

原文地址:https://www.cnblogs.com/MySpace/p/1607653.html