alter proc s6
AS
declare @trade_co char(10),
@a char(20),
@b char(20),
@c char(20),
@k int
select @k=0
declare hh_cursor cursor for
select trade_co,
A,
B,
C
from IM_ENTRY_HEAD
where datediff(day,D_Date,getdate())=0 And LEFT(PROCESS_MARK,2)<>'1B'
open hh_cursor
fetch next from hh_cursor
into @trade_co,
@a,
@b,
@c
while @@FETCH_STATUS = 0
begin
select @k=@k+1
if exists(select trade_co where trade_co=@trade_co and A=@a and B=@b and C=@c)
begin
update total set num=num+1 where trade_co=@trade_co and A=@a and B=@b and C=@c
update total set allnum=allnum+1 where trade_co=@trade_co and A=@a and B=@b and C=@c
update total set p=num/allnum
end
else
begin
insert into total (trade_co,A,B,C,num) values(@trade_co,@a,@b,@c,1)
update total set allnum=(select distinct allnum from total where trade_co=@trade_co)
update total set p=num/allnum
end
fetch next from hh_cursor into
@trade_co,
@a,
@b,
@c
你该看一下数据库的排序规则,
select * from syscolumns where name in ('A','B','C') --where id=object_id('total')
select * from syscolumns where name in ('a','b','c') --where id=object_id('total')
看看是不是有结果