了解sql函数 [英] understanding sql functions

查看:116
本文介绍了了解sql函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果项目中的count(问题)为0

返回1

否则if(count(issue)> 0和count(issue)< 5)

返回0

其他

返回-1



我要创建功能对于上面的sql ...

请给我打电话怎么办

if count(issue) in project is 0
return 1
else if(count(issue)>0 and count(issue)<5)
return 0
else
return -1

I want to create function for above in sql...
Please tel me how to do

推荐答案

You can try this function




create function Check_Issue()
 returns  int
   As
     begin
      Declare @count int
      Declare @result int
        select @count = count(issue) from project   --take value in one variable
           if (@count = 0 )                          -- check in if loop
            Begin
              set  @result = 1
            End
            else if (@Count > 0 and @count < 5)
              set  @result = 0
            else
              set  @result = -1
       return @result                               -- return value
   End


这篇关于了解sql函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆