标签:ar sp on bs as 时间 new nbsp sql
use db_buiness
go
select *from dbo.仓库 where 城市=‘北京‘
select distinct(城市), 仓库号 from dbo.仓库 //取消重复的列值
select SUM (工资)as 总工资 from dbo.职工
select 仓库号,城市,面积 from dbo.仓库 where not 城市=‘北京‘
select * from 职工 where 工资 between 1000 and 1500
select * from 职工 where 性别 in(‘男‘)
select * from 职工 where 性别 is null
select * from 职工 where 姓名 like ‘%平%‘ //%代表多个字符
select * from 职工 where 姓名 like ‘_平_‘ //下划线代表一个字符
select top 10 * from dbo.职工
select * from 职工 order by 职工ID
select * from 职工 order by NEWID() //NEWID() 随机排序
select avg (工资)as 平均工资 from dbo.职工
select max(工资)as 最高工资 from dbo.职工
select min (工资)as 最低工资 from dbo.职工
select count (*)as 总记录 from dbo.职工
select COUNT (distinct(仓库号))as 仓库总数 from 仓库
select MAX (工资)-MIN (工资)as 工资差 from 职工
select 仓库号 ,max(工资)as 不同仓库的最高工资 from 职工 group by 仓库号
select 仓库号 ,AVG (工资)as 不同仓库的平均工资 from 职工 group by 仓库号 having AVG (工资 ) >1000
select 仓库号,性别 ,MIN (工资)as 不同仓库的最低工资 from 职工 group by 仓库号,性别
select 姓名,SUBSTRING(姓名,1,1)as 姓氏,SUBSTRING (姓名,2,2)as 名子 from 职工
select 仓库号,UPPER(仓库号) as 仓库号大写,面积 from 仓库
select 仓库号,LOWER (仓库号)as 仓库号小写, 面积 from 仓库
select 仓库号,CONVERT(char(10),创建时间,111) as 创建时间 from 仓库 //111代表日期格式 yy/mm/dd
标签:ar sp on bs as 时间 new nbsp sql
原文地址:http://www.cnblogs.com/zhangjd/p/4154057.html