sql server 一个简单的函数

来源:互联网 发布:python量化交易pdf 编辑:程序博客网 时间:2024/06/05 05:10

 create function uu() returns varchar(8000)
as
begin
declare @x numeric(8,2), @y numeric(8,2)
declare @str varchar(1000)

set @x=(select avg(zhi) from ttt where seq=11)

set @y=(select avg(zhi) from ttt where seq=12)


if (@x> @y)

  set @str=   '部门 10 平均工资高于部门 20'

else

   set @str=  '部门 10 平均工资低于部门 20'

return (@str)
end