H
hurryman
Unregistered / Unconfirmed
GUEST, unregistred user!
請教SQL高手
declare getstaffer cursor
for select w_code , w_conflag , w_grade , w_group from staffer order by w_code
open getstaffer
fetch next from getstaffer into @wd_code ,@hy ,@grade ,@group
while @@fetch_status=0
begin
/*平日上班時間*/
select @nl_hrs=sum(w_hrs) from dktotb where w_code=@wd_code and w_tag='N' and w_tagadd='N'
update wsaler set w_h1=@nl_hrs where w_code=@wd_code
/*正常加班*/
select @nl_addhrs=sum(w_hrs) from dktotb where w_code=@wd_code and w_tag='N' and w_tagadd='A'
update wsaler set w_nrot1=@nl_addhrs where w_code=@wd_code
這是我的一個模塊的后台,
我現在碰到一個怪問題:
/*平日上班時間*/下面的兩句向一直界得不到結果
/*正常加班*/下面兩句可以得到結果
但是當我只執行
select sum(w_hrs) from dktotb where w_code='11111' and w_tag='N' and w_tagadd='N'
update wsaler set w_h1=@nl_hrs where w_code='11111'
又可以,我實在不知如何解決,大家幫幫我
declare getstaffer cursor
for select w_code , w_conflag , w_grade , w_group from staffer order by w_code
open getstaffer
fetch next from getstaffer into @wd_code ,@hy ,@grade ,@group
while @@fetch_status=0
begin
/*平日上班時間*/
select @nl_hrs=sum(w_hrs) from dktotb where w_code=@wd_code and w_tag='N' and w_tagadd='N'
update wsaler set w_h1=@nl_hrs where w_code=@wd_code
/*正常加班*/
select @nl_addhrs=sum(w_hrs) from dktotb where w_code=@wd_code and w_tag='N' and w_tagadd='A'
update wsaler set w_nrot1=@nl_addhrs where w_code=@wd_code
這是我的一個模塊的后台,
我現在碰到一個怪問題:
/*平日上班時間*/下面的兩句向一直界得不到結果
/*正常加班*/下面兩句可以得到結果
但是當我只執行
select sum(w_hrs) from dktotb where w_code='11111' and w_tag='N' and w_tagadd='N'
update wsaler set w_h1=@nl_hrs where w_code='11111'
又可以,我實在不知如何解決,大家幫幫我