查询语句 转成 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;