DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: hxh57738897
今日帖子: 23
在线用户: 23
导航: 论坛 -> 数据库专区 斑竹:liumazi,waterstone  
作者:
女 qimu (yunyun) ★☆☆☆☆ -
普通会员
2003/10/13 14:21:51
标题:
怎么样才能才数据库里的记录值显示为0! 浏览:2657
加入我的收藏
楼主: 我用下面的语句在更新dayrep表时当count(servicetimes),sum(servicecount)统计的结果为0时,为什么dayrep表的相应记录的值却不为0,而是空的呢,怎么样才能让这个值显示为0呢!字段servicetimes,servicecount的数据类型为demical类型!
SQLStatement:='update dayrep set(dayservicetimes,dayservicecount,daytotalfee) = ';
      SQLStatement:=SQLStatement+' (select count(servicetimes),sum(servicecount),sum(TOTALFEE) from '+MyTableName;
      SQLStatement:=SQLStatement+' where trim('+MyTableName+'.calledid) = trim(dayrep.calledid)';
      SQLStatement:=SQLStatement+' and servicestarttime > :DateTime1';
      SQLStatement:=SQLStatement+' and servicestarttime < :DateTime2';
      SQLStatement:=SQLStatement+' group by CALLEDID)';
----------------------------------------------
你是我的最爱!
作者:
男 givemeliu (delphi傻瓜) ★☆☆☆☆ -
盒子活跃会员
2003/10/13 17:49:15
1楼: 你可以先查寻在判断然后附值;
var sertime,sercount,daytotal:integer;
 trySQLStatement:=' (select count(servicetimes)as sertime,sum(servicecount)as sercount,sum(TOTALFEE)as total from '+MyTableName;
      trySQLStatement:=trySQLStatement+' where trim('+MyTableName+'.calledid) = trim(dayrep.calledid)';
      trySQLStatement:=trySQLStatement+' and servicestarttime > :DateTime1';
      trySQLStatement:=trySQLStatement+' and servicestarttime < :DateTime2';
      trySQLStatement:=trySQLStatement+' group by CALLEDID)'; 
query1.close;
query1.sql.clear;
query1.sql.add(SQLStatement);
query1.open;
if not query1.eof then
begin
sertime:=query1.fieldbyname('sertime').asfloat;
sercount:=query1.fieldbyname('sercount').asfloat;
daytotal:=query1.fieldbyname('total').asfloat;
end;
SQLStatement:='update dayrep set(dayservicetimes,dayservicecount,daytotal
fee) = ';

SQLStatement:=SQLStatement+inttostr(sertime)+','+inttostr(sercount)+','+daytotal

----------------------------------------------
我们共同努力,一切问题都会解决
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行66.40625毫秒 RSS