请教:怎么用Delphi 7 按年、月、日查询SQL Server 2005 数据库的表的其中几列(D1和D2),显示,并生成合计?数据库表:
date D1 D11 D2 D21
2009/10/18 33 2 43 2
2009/10/18 43 2 54 2
2009/10/19 50 8 30 3.3
2009/10/19 49 3 34 2输入查询条件2009/10/19,要求运行生成:date D1 D11 D2 D21
2009/10/19 50 8 30 3.3
2009/10/19 49 3 34 2
合计 99 64谢谢!
date D1 D11 D2 D21
2009/10/18 33 2 43 2
2009/10/18 43 2 54 2
2009/10/19 50 8 30 3.3
2009/10/19 49 3 34 2输入查询条件2009/10/19,要求运行生成:date D1 D11 D2 D21
2009/10/19 50 8 30 3.3
2009/10/19 49 3 34 2
合计 99 64谢谢!
UNION all
select '合计',sum(d1),'',sum(d2),'',from table where date='2009/10/19' Group by date其实date限定后 Group by 没用
select year,yljl01,yljl02,yljl03,yljl04 from tljl where year='2009'
UNION all
select '合计',sum(yljl01),'',sum(yljl03),''from tljl where year='2009' group by year
翻译成Delphi的代码啊?谢谢!
temp1,temp2:String;
begin
temp1:='2009-10-10';
temp2:='合计';
adoquery1.close;
adoquery1.sql.clear;
adoquery1.sql.add('select year,yljl01,yljl02,yljl03,yljl04');
adoquery1.sql.add('from tljl where year='+''''+temp1+''''+ 'UNION all');
adoquery1.sql.add(' select '+''''+temp2+''''+',sum(yljl01),'',sum(yljl03),''');
adoquery1.sql.add('from tljl where year='+''''+temp2+''''+' group by year');
adoquery1.open;
end;code]
temp1,temp2:String;
begin
temp1:='2009-10-10';
temp2:='合计';
adoquery1.close;
adoquery1.sql.clear;
adoquery1.sql.add('select year,yljl01,yljl02,yljl03,yljl04');
adoquery1.sql.add('from tljl where year='+''''+temp1+''''+ 'UNION all');
adoquery1.sql.add(' select '+''''+temp2+''''+',sum(yljl01),'',sum(yljl03),''');
adoquery1.sql.add('from tljl where year='+''''+temp2+''''+' group by year');
adoquery1.open;
end;
另外请教下:在rave报表中增加一个band1,添加calctext,但是运行时calctext下什么都没有,怎么回事?calctype选的是ctsum,请教!