SqlServer和Oracle中一些常用的sql语句4 局部/全局变量

来源:互联网 发布:淘宝账号忘了怎么办 编辑:程序博客网 时间:2024/05/22 00:54
--把wh1仓库号中姓名含有"平"字的职工工资在原来的基础上加288update 职工备份 set 工资=工资+288 where 仓库号='wh1' and 姓名 like '%平%'--把"北京"地区的职工的工资减少100,再增加1倍update 职工备份 set 工资=(工资-100)*2 where 仓库号 in   (select 仓库号 from 仓库备份 where 城市='北京')   --把面积小于"北京"地区最小面积的仓库面积增加80update 仓库备份 set 面积=面积+80 where 面积<  ( select MIN(面积) from 仓库备份 where 城市='北京')  --把工资大于不同仓库的所有平均工资的职工的工资减少66  update 职工备份 set 工资=工资-66 where 工资> all(   select AVG(工资) from 职工备份 group by 仓库号)--删除面积最大和最小的仓库信息   delete 仓库备份 where 面积 in ( (select MAX(面积) from 仓库备份),(select min(面积) from 仓库备份))   --删除工资大于所有职工平均工资的职工信息delete 职工备份 where 工资> (select AVG(工资) from 职工备份 )--删除"上海","济南"的所有职工信息delete 职工备份 where 仓库号 in    (select 仓库号 from 仓库备份  where 城市 in('上海','济南'))--局部变量声明 赋值 输出 declare @str1 char(10),@str2 varchar(50), @x1 int, @x2 real,@time1 datetimeset @str1='good'set @str2='hello,how are you?'set @x1=12set @x2=15set @time1='2009/05/06'print @str1print @str2print @x1print @x2print @time1--局部变量声明 赋值 输出declare @str1 char(10),@str2 varchar(50), @x1 int, @x2 real,@time1 datetimeselect @str1='good',@str2='hello,how are you?',@x1=12,@x2=15,@time1='2009/05/06'select @str1 as 字符变量1,@str2 as 字符变量2,       @x1 as 整型变量1,@x2 as 整型变量2,@time1 as 日期时间变量--局部变量declare @x intset @x=2000select * from 职工 where 工资>@x--全局变量PRINT @@version

原创粉丝点击