var
sumwz0,sumwz1,sumwz2,sumwz3,sumwz4 :string;
begin
with Query1 do
begin
Close;
SQL.Clear;
SQL.Add(' Select sum(je) as sumwz0 from temp.db where hm=wz0 ');
SQL.Add(' Select sum(je) as sumwz1 from temp.db where hm=wz1 ');
SQL.Add(' Select sum(je) as sumwz2 from temp.db where hm=wz2 ');
SQL.Add(' Select sum(je) as sumwz3 from temp.db where hm=wz3 ');
SQL.Add(' Select sum(je) as sumwz4 from temp.db where hm=wz4 ');
Open;
PrePare;
sumwz0:=FieldByName('sumwz0').AsString;;
sumwz1:=FieldByName('sumwz1').AsString;;
sumwz2:=FieldByName('sumwz2').AsString;;
sumwz3:=FieldByName('sumwz3').AsString;;
sumwz4:=FieldByName('sumwz4').AsString;;
end;
end;
end.
我是想求的sumwz0..sumwz4的值打印它,上面的不行!
sumwz0,sumwz1,sumwz2,sumwz3,sumwz4 :string;
begin
with Query1 do
begin
Close;
SQL.Clear;
SQL.Add(' Select sum(je) as sumwz0 from temp.db where hm=wz0 ');
SQL.Add(' Select sum(je) as sumwz1 from temp.db where hm=wz1 ');
SQL.Add(' Select sum(je) as sumwz2 from temp.db where hm=wz2 ');
SQL.Add(' Select sum(je) as sumwz3 from temp.db where hm=wz3 ');
SQL.Add(' Select sum(je) as sumwz4 from temp.db where hm=wz4 ');
Open;
PrePare;
sumwz0:=FieldByName('sumwz0').AsString;;
sumwz1:=FieldByName('sumwz1').AsString;;
sumwz2:=FieldByName('sumwz2').AsString;;
sumwz3:=FieldByName('sumwz3').AsString;;
sumwz4:=FieldByName('sumwz4').AsString;;
end;
end;
end.
我是想求的sumwz0..sumwz4的值打印它,上面的不行!
解决方案 »
- 求救!!Inno Setup 文件关联
- 急,在线等:一个sql查询语句的问题,高手请赐教
- 窗体间消息的传递
- 跨网段使用sqlserver,支持事务处理的COM+报“新事务不能登记到指定的事务处理器中”?
- 寻人启事:寻了解甚至熟悉用KOL框加开发小EXE的朋友。
- 菜鸟求知:在delphi中如何加入新的功能模块到类似outlook风格中去?
- 基于paradox的SQL语句,如何将值为null的数字字段转换为0啊?
- HP 5L打印机在win2000server下面安装后,怎么就不能使用呢?
- 怎么让文本框中的文字居右对齐?
- 如何把tmemorystream对象 完整的拷贝到令一个tmemorystream对象??
- 获取指定目录下的所有目录列表(包括子目录),
- 哪里有关于Delphi和Oracle数据库程序设计的资料?
where( hm=wz1 or hm=wz2 or hm=wz3 or hm=wz4) group by hm
SQL.Add('( Select 1 as t, sum(je) as sumwz0 from temp.db where hm=wz0 ) a join');
SQL.Add('( Select 1 as t, sum(je) as sumwz1 from temp.db where hm=wz1) b on a.t=b.t join');
SQL.Add(' (Select 1 as t, sum(je) as sumwz2 from temp.db where hm=wz2 ) c on c.t=b.t join');
SQL.Add('( Select 1 as t, sum(je) as sumwz3 from temp.db where hm=wz3) d on d.t = c.t join ');
SQL.Add('( Select 1 as t, sum(je) as sumwz4 from temp.db where hm=wz4) e on e.t=d.t');不过这样的语句不是很好,你的问题应该可以用别的方法实现。
SQL.Add(' Select sum(je) as sumwz0 from temp.db where hm=wz0 ');
SQL.Add(' union ');
SQL.Add(' Select sum(je) as sumwz1 from temp.db where hm=wz1 ');
SQL.Add(' union ');
...