declare @customerid as varchar(10);
declare c cursor FAST_FORWARD for select distinct customerid from ys where change<0;
open c
fetch next from c into @customerid;
while @@fetch_status=0
begin
select top 1 customerid,change from ys where change<0 and customerid = @customerid order by liushuiriqi desc;
end
close c;
deallocate c;
出来那么多结果,重复了一遍又一遍,不知道为什么
declare c cursor FAST_FORWARD for select distinct customerid from ys where change <0;
open c
fetch next from c into @customerid;
while @@fetch_status=0
begin
select top 1 customerid,change from ys where change <0 and customerid = @customerid order by liushuiriqi desc;
fetch next from c into @customerid;
end
close c;
deallocate c;