28,391
社区成员
发帖
与我相关
我的任务
分享
use sh2
select *,(convert(varchar,(cast(
(convert(decimal,pg1)*3+convert(decimal,pg2)*2
+convert(decimal,pg3)*1-convert(decimal,pg4)*1-convert(decimal,pg5)*2
-convert(decimal,pg6)*3)/
(convert(decimal,zs)*3)*100 as decimal(15,2))))+'%')
as myd1,(cast(
(convert(decimal,pg1)*3+convert(decimal,pg2)*2
+convert(decimal,pg3)*1-convert(decimal,pg4)*1-convert(decimal,pg5)*2
-convert(decimal,pg6)*3)/
(convert(decimal,zs)*3)*100 as decimal(15,2))) as myd,
convert(varchar,(convert(decimal(10,2),round(ywc*1.00/zs,2))*100))+'%') as wcl from (
select
a.serviceid,
a.xm,
a.zu,
count(b.id) as zs,
(select name from zu where id=a.zu) as name ,
(select count(wenti.id) from wenti where (typeid=4 ) and service=a.serviceid) as ywc,
(select count(wenti.id) from wenti where (typeid<>4 ) and (typeid<>7) and service=a.serviceid) as clz,
(select count(wenti.id) from wenti where (typeid=7 ) and service=a.serviceid) as dfk,
(select count(wenti.id) from wenti where typeid=4 and service=a.serviceid and pg=1) as pg1,
(select count(wenti.id) from wenti where typeid=4 and service=a.serviceid and pg=2) as pg2,
(select count(wenti.id) from wenti where typeid=4 and service=a.serviceid and pg=3) as pg3,
(select count(wenti.id) from wenti where typeid=4 and service=a.serviceid and pg=4)as pg4,
(select count(wenti.id) from wenti where typeid=4 and service=a.serviceid and pg=5) as pg5,
(select count(wenti.id) from wenti where typeid=4 and service=a.serviceid and pg=6) as pg6
from service as a left join wenti as b on a.serviceid=b.service where b.id>0
group by a.serviceid,a.xm,a.zu ) as table1 order by zu, myd desc
strSql= "select *,(convert(varchar,(cast((convert(decimal,pg1)*3+convert(decimal,pg2)*2+convert(decimal,pg3)*1-convert(decimal,pg4)*1-convert(decimal,pg5)*2-convert(decimal,pg6)*3)/(convert(decimal,zs)*3)*100 as decimal(15,2))))+'%') as myd1,(cast((convert(decimal,pg1)*3+convert(decimal,pg2)*2+convert(decimal,pg3)*1-convert(decimal,pg4)*1-convert(decimal,pg5)*2-convert(decimal,pg6)*3)/(convert(decimal,zs)*3)*100 as decimal(15,2))) as myd, convert(varchar,(convert(decimal(10,2),round(ywc*1.00/zs,2))*100))+'%') as wcl from (select a.serviceid,a.xm,a.zu,count(b.id) as zs,(select name from zu where id=a.zu) as name , (select count(wenti.id) from wenti where (typeid=4 ) and service=a.serviceid) as ywc, (select count(wenti.id) from wenti where (typeid=7 ) and service=a.serviceid) as dfk,(select count(wenti.id) from wenti where (typeid<>4 ) and (typeid<>7) and service=a.serviceid) as clz,(select count(wenti.id) from wenti where typeid=4 and service=a.serviceid and pg=1) as pg1,(select count(wenti.id) from wenti where typeid=4 and service=a.serviceid and pg=2) as pg2,(select count(wenti.id) from wenti where typeid=4 and service=a.serviceid and pg=3) as pg3,(select count(wenti.id) from wenti where typeid=4 and service=a.serviceid and pg=4)as pg4,(select count(wenti.id) from wenti where typeid=4 and service=a.serviceid and pg=5) as pg5,(select count(wenti.id) from wenti where typeid=4 and service=a.serviceid and pg=6) as pg6 from service as a left join wenti as b on a.serviceid=b.service where b.id>0 group by a.serviceid,a.xm,a.zu ) as table1 order by zu,myd desc"
rs.open strSql,conn,1,1
convert(varchar,(convert(decimal(10,2),round(ywc*1.00/zs,2))*100))+'%') as wcl
移除,就不会报错,但是这一句必须要用到,而且在sqlserver中也能正常的查询到记录,然后我改成了rs.open strSql,conn,1,3
create proc myproc
as
use sh2
select *,(convert(varchar,(cast(
(convert(decimal,pg1)*3+convert(decimal,pg2)*2
+convert(decimal,pg3)*1-convert(decimal,pg4)*1-convert(decimal,pg5)*2
-convert(decimal,pg6)*3)/
(convert(decimal,zs)*3)*100 as decimal(15,2))))+'%')
as myd1,(cast(
(convert(decimal,pg1)*3+convert(decimal,pg2)*2
+convert(decimal,pg3)*1-convert(decimal,pg4)*1-convert(decimal,pg5)*2
-convert(decimal,pg6)*3)/
(convert(decimal,zs)*3)*100 as decimal(15,2))) as myd,
convert(varchar,(convert(decimal(10,2),round(ywc*1.00/zs,2))*100))+'%') as wcl from (
select
a.serviceid,
a.xm,
a.zu,
count(b.id) as zs,
(select name from zu where id=a.zu) as name ,
(select count(wenti.id) from wenti where (typeid=4 ) and service=a.serviceid) as ywc,
(select count(wenti.id) from wenti where (typeid<>4 ) and (typeid<>7) and service=a.serviceid) as clz,
(select count(wenti.id) from wenti where (typeid=7 ) and service=a.serviceid) as dfk,
(select count(wenti.id) from wenti where typeid=4 and service=a.serviceid and pg=1) as pg1,
(select count(wenti.id) from wenti where typeid=4 and service=a.serviceid and pg=2) as pg2,
(select count(wenti.id) from wenti where typeid=4 and service=a.serviceid and pg=3) as pg3,
(select count(wenti.id) from wenti where typeid=4 and service=a.serviceid and pg=4)as pg4,
(select count(wenti.id) from wenti where typeid=4 and service=a.serviceid and pg=5) as pg5,
(select count(wenti.id) from wenti where typeid=4 and service=a.serviceid and pg=6) as pg6
from service as a left join wenti as b on a.serviceid=b.service where b.id>0
group by a.serviceid,a.xm,a.zu ) as table1 order by zu, myd desc
set rs=conn.execute("myproc")