首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

查询话语 转成 delphi代码模式

2013-10-16 
查询语句 转成 delphi代码模式selectformat( count(YGZ_MC)*100 / (select count(YGZ_MC) from tablename

查询语句 转成 delphi代码模式
select  format( count(YGZ_MC)*100 / (  select count(YGZ_MC) from tablename where JZJTSJTS =0 )   ,"#.00" ) + "%"  as 户数占比 from tablename where JZJTSJTS =0 
主要卡在  ,"#.00" ) + "%"  这块的转换上了,上面的代码在SQL查询分析器中好用,想转成delphi 中代码 string 存储;string a := '  ';
请高手指教。


[解决办法]
,"#.00" ) + "%" 

都是是双引号, 是不需要做转换的.

string a := 'select  format( count(YGZ_MC)*100 / (  select count(YGZ_MC) from tablename where JZJTSJTS =0 )   ,"#.00" ) + "%"  as 户数占比 from tablename where JZJTSJTS =0';

[解决办法]
var 
SQLText :widestring;
begin
  SQLText :='select convert(varchar(5),cast(count(YGZ_MC)*100.00/(select count(YGZ_MC) from tablename where JZJTSJTS=0) as decimal(5,2)))+''%'' as 户数占比 from tablename where JZJTSJTS =0'; 
//......
end;

热点排行