问题简单:
首先明确,你的计算在前台还是后台作。你的数据库是什么类型的。
如果在前台做。
处理Query1.SQL: Select Tel_Code,Tel_Money from table_sam
Query1.Open;
Query1.First;
while not Query1.eof do
begin
  str_TelCode := Query1.Fields[0].AsString;
  ------ 处理
  Query1.Next;
end;

解决方案 »

  1.   

    Select d.dhhm,
      (select dhhm,fei from DD where substr(dhhm,1,1)='0',
      (select dhhm,fei from DD where substr(dhbh,2,1)='0') ,
      (select dhhm,fei from DD where substr(dhhm,1,1)<>'0' and substr(dhhm,2,1)<>'0') 
       from DD;这是oracle数据库.不同的数据库可能不一样.
      

  2.   

    以上所讲的DELPHI前台处理已经够了.实际上我觉得你在服务器端判断,计算传回一个总金额可能更好!