with dm.Q2 do
begin
close;
sql.Clear;
sql.add('select sum(case Yh_Type=''照明用户'' then 1 else 0 end),'+'sum(case Yh_Type=''动力用户'' then 1 else 0 end),'+'sum(case Yh_Type=''公用变压器'' then 1 else 0 end),'+'sum(case Yh_Type=''私用变压器'' then 1 else 0 end) from alteramm');
open;
lzm.Caption:='照明用户换表共:'+fields[0].AsString+'只';
ldl.Caption:='动力用户换表共:'+fields[1].AsString+'只';
lpub.Caption:='公用变压器换表共:'+fields[2].AsString+'只';
lprivy.Caption:='私用变压器换表共:'+fields[3].AsString+'只';
end;
出错提示为:‘=附近有语法错误’!????????????????????
begin
close;
sql.Clear;
sql.add('select sum(case Yh_Type=''照明用户'' then 1 else 0 end),'+'sum(case Yh_Type=''动力用户'' then 1 else 0 end),'+'sum(case Yh_Type=''公用变压器'' then 1 else 0 end),'+'sum(case Yh_Type=''私用变压器'' then 1 else 0 end) from alteramm');
open;
lzm.Caption:='照明用户换表共:'+fields[0].AsString+'只';
ldl.Caption:='动力用户换表共:'+fields[1].AsString+'只';
lpub.Caption:='公用变压器换表共:'+fields[2].AsString+'只';
lprivy.Caption:='私用变压器换表共:'+fields[3].AsString+'只';
end;
出错提示为:‘=附近有语法错误’!????????????????????
sql.add('select sum(case Yh_Type="照明用户" then 1 else 0 end),'+'sum(case Yh_Type="动力用户" then 1 else 0 end),'+'sum(case Yh_Type="公用变压器" then 1 else 0 end),'+'sum(case Yh_Type="私用变压器" then 1 else 0 end) from alteramm');
应该是sum(),sum(),sum()吧?