我正在尝试计算特定时期内休假的人数,然后使用总数插入我要报告的表格中。 如果在选定的期间内有人休假,则给我计数,如果n
o事务仅表示命令已完成,但不返回任何数据,我希望它返回NULL或O。
declare @SUSPENDED smallint
--
declare templ cursor for
Select (select (COUNT(leave))where leave = 'Suspend Unpaid')as Suspended
from A_EMPDAILYSTATUS Where PAYPERIOD = (SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()-35),0))and leave = 'Suspend Unpaid'
group by LEAVE
-- OPEN TEMP FILES
open templ
fetch next from templ into @Suspended
while @@fetch_status = 0
begin
select @SUSPENDED AS SUSPENDED
fetch next from templ into @Suspended
end
set nocount off
Deallocate templ