当前位置: 代码迷 >> Sql Server >> 求指教SQL函数解决思路
  详细解决方案

求指教SQL函数解决思路

热度:69   发布时间:2016-04-27 12:38:27.0
求指教SQL函数
[email protected],求指教!!!
这个函数只是来算一下某一读者借了多少本书
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 [email protected]
group by readerId;
return @num;
end


------解决方案--------------------
SQL code
create function numBook(@readerName varchar(20))returns intasbegindeclare @num int;select @num=COUNT(*) from t_borrow,t_reader2  where t_borrow.readerId=t_reader2.readerId  and [email protected]group by readerId;return @num;end--select count(*) into @num是Oracle中的语法
------解决方案--------------------
探讨

oh。。。我错了,用group by只是同学建议我试试。。。现在去掉了,然后也改过来了,不报错了。多谢啊!那个,再弱弱的问,要怎么调用啊。。。
  相关解决方案