快递网站制作,租一个网站服务器多少钱,广州建站平台哪家好,仿冒网站制作一.函数
函数调用格式#xff1a;
select 表名.该表中创建的函数 1.系统函数
系统中自带的函数#xff0c;比如聚合函数#xff08;sum等等#xff09; 2.自定义函数
#xff08;1#xff09;.标量值函数#xff08;只返回单个值#xff09;
举例#xff1a;我们…一.函数
函数调用格式
select 表名.该表中创建的函数 1.系统函数
系统中自带的函数比如聚合函数sum等等 2.自定义函数
1.标量值函数只返回单个值
举例我们创建了一个Student学生表现在要求写出一个函数求出其中所有学生的分数总和
create function GetScore()
returns score
as
begin declare AllScore int select AllScore (select SUM(Score) from Student) return AllScore
end --调用函数
select mydatabase.GetScore 2.表值函数返回查询结果
举例在Student学生表中目前对函数的要求是通过传入学生编号返回学生姓名
create function GetName(id int)
returns varchar(30)
as
begin declare name varchar(30) select name (select Name from Student where StudentId id) return name
end--调用函数
select mydatabase.GetName(1)