*!* 建立1个表,并插入测试数据
create cursor tt(TH1 C(4),TH2 C(4),SL I)
insert into tt(TH1,TH2,SL) values('A', 'Z', 1)
insert into tt(TH1,TH2,SL) values('A', 'X', 2)
insert into tt(TH1,TH2,SL) values('A', 'Z', 3)
insert into tt(TH1,TH2,SL) values('A', 'X', 1)
insert into tt(TH1,TH2,SL) values('B', 'Z', 1)
insert into tt(TH1,TH2,SL) values('B', 'Z', 1)
insert into tt(TH1,TH2,SL) values('B', 'X', 2)
insert into tt(TH1,TH2,SL) values('B', 'Z', 3)
insert into tt(TH1,TH2,SL) values('B', 'X', 1)
insert into tt(TH1,TH2,SL) values('C', 'Z', 1)
insert into tt(TH1,TH2,SL) values('C', 'Z', 1)
insert into tt(TH1,TH2,SL) values('C', 'X', 2)
insert into tt(TH1,TH2,SL) values('C', 'Z', 3)
insert into tt(TH1,TH2,SL) values('C', 'X', 1)
brow
*!* 统计你要的结果到 表 t2
select TH1,TH2,sum(SL) as SL from tt into cursor t2 group by TH1,TH2
select t2
brow