select age,count(*) from employee group by age having salary>2000
//having是对分组后的信息的过滤,能用的列和select中能用的列是一样的
select top 3 from person2 order by age desc
alter table employee add company vchar(20);//增加字段
selectdistinctcompanyfromperson2;//消除重复的数据
union //联合查询结果,数据列数一致,类型相同,默认合并重复的数据
union all //不合并重复的数据
数据类型转换
cast
convert
空置处值函数
isnull(name,'dc')
单值判断,相当于switch
case expression
when value1 then returnvalue1
when value2 then returnvalue2
when value3 then returnvalue3
else defaultreturnvalue
end
同时支持范围值