select @BranchID=select id from branch where BranchName='财务部'
有错误,应该
select @BranchID=[id] from branch where BranchName='财务部'
有错误,应该
select @BranchID=[id] from branch where BranchName='财务部'
解决方案 »
- row_number over 的问题
- “2007-12-15”至“2008-1-8”时间段内的 where 条件咋写 跪求中
- 怎么判断是系统返回的错误还是自己RAISERROR出来的错误?
- 怎么才能知道一个表中有多少个字段?
- {?}怎么在Mysql-font 里添加字段时做乘法..快来帮忙
- 数据库同步问题,SQL语句的问题
- 连接局域网服务器sql2000的问题(高分求高手解答)
- 一个想不明白的问题
- ASP.NET中用代码如何实现对数据库字段的添加?
- 在存储过程中,不用游标怎样实现根据查询结果执行另外的存储过程?在线等待-100分
- 请问在存储过程中定义的变量有没有超过varchar的?
- ACCESS语句出了毛病,请帮忙解决!
也有错误,应该
declare @BranchID tinyint
CREATE PROCEDURE GetBranchStatic
AS
declare @BranchID tinyint
select sum(case when branchID=@BranchID then 1 else 0 end )AS total
from employee
select @BranchID=[id] from branch where BranchName='财务部'GO
AS
declare @BranchID tinyint
select sum(case when branchID=@BranchID then 1 else 0 end )AS total
from employee select @BranchID=(select id from branch where BranchName='财务部')
CREATE PROCEDURE GetBranchStatic
AS
declare @BranchID tinyint
select @BranchID=[id] from branch where BranchName='财务部'
select sum(case when branchID=@BranchID then 1 else 0 end ) AS total
from employee
GO
如果想统计结果存在一个以年份为开始名称的表中,比如要将现在的结果
存在
2004static表中,怎样写这个存储过程?比如到了2005年,统计的结果则存放在
2005static表中.再次感谢.马上结分.
AS
--表名称
declare @tableName=substring(cast(getdate() as varchar),0,4)+'static'declare @BranchID tinyint
select @BranchID=[id] from branch where BranchName='财务部'
select sum(case when branchID=@BranchID then 1 else 0 end ) AS total
from @tableName
GO
AS
--表名称
declare @tableName=substring(cast(getdate() as varchar(20)),0,4)+'static'declare @BranchID tinyint
select @BranchID=[id] from branch where BranchName='财务部'
select sum(case when branchID=@BranchID then 1 else 0 end ) AS total
from @tableName
GO