这个因为任务比较赶,只能有针对性的学习,希望各位大大能说下要用到哪些,然后我去学习= = 作者: kider 时间: 2011-9-29 09:45
一条SQL就应该可以搞定:
select id, sum(turnover) as turnover from table group by id order by id;作者: je_ck 时间: 2011-9-30 09:10
order by id
kider确定 ?作者: yuanzai32 时间: 2011-10-24 16:01
kider 发表于 2011-9-29 09:45
一条SQL就应该可以搞定:
select id, sum(turnover) as turnover from table group by id order by id;
begin
DECLARE amount decimal;
DECLARE Salesman,statDate varchar(128);
DECLARE mark int;
delete from skt68; //这句起什么用呢
SET mark=0; 作者: yuanzai32 时间: 2011-10-27 09:33
if (dateType='Year') then
begin
DECLARE curdeal_1 CURSOR FOR
select sum(skt43.skf610),skt57.skf772,CONCAT(YEAR(skt43.skf611)) from skt57 left join (skt43,skt42) on (skt43.skf616//所在合同=skt42.skf587//合同编号 and skt57.skf772//办事处人员编号=skt42.skf589//合同表业务员 and skt43.skf615//来自哪个合同=1 and skt43.skf611//收款时间>=dateBegin and skt43.skf611收款时间<=dateEnd) GROUP BY (CONCAT(YEAR(skt43.skf611))),skt57.skf772//办事处人员编号;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET mark=1;
open curdeal_1;
repeat
FETCH curdeal_1 into amount,Salesman,statDate;
if(mark < 1)then
if (Salesman not in ('138','132'))then
begin
INSERT INTO skt68 (SKF911,SKF909,SKF910) select tblemployee.Name,statDate,amount from tblemployee where tblemployee.ID=Salesman;
end;
end if;
end if;
UNTIL mark=1
end REPEAT;
CLOSE curdeal_1;
end;