求指教SQL函数 写个函数发现总是说第六行@num附近有错误,求指教!!! 这个函数只是来算一下某一读者借了多少本书 create function numBook(@readerName varchar(20)) returns int as begin declare @num int; select COUNT(*) into @num from t_borrow,t_reader2 where t_borrow.readerId=t_reader2.readerId and t_reader2.readerName=@readerName group by readerId; return @num; end
------解决方案--------------------
SQL code
create function numBook(@readerName varchar(20))
returns int
as
begin
declare @num int;
select @num=COUNT(*)
from t_borrow,t_reader2
where t_borrow.readerId=t_reader2.readerId
and t_reader2.readerName=@readerName
group by readerId;
return @num;
end
--select count(*) into @num是Oracle中的语法
------解决方案--------------------