# 做除法运算,用ASP代码如何写

www.MyException.Cn  网友分享于：2013-03-14  浏览：83次

<%
dim   rshgr1
dim   sqlhgr1

sqlhgr1= "select   count(id)   as   hgrs1   from   scores   where   language> =60       and   grade= "&grade& "   and   class= "&banji& " "                     '查询语文成绩合格人数
on   error   resume   next
rshgr1.Open   sqlhgr1,conn,1
%>

<%
dim   rshgl1
dim   sqlhgl1

sqlhgl1= "select   count(*)   as   zrsh   from   scores   where     grade= "&grade& "   and   class= "&banji& " "       '查询总人数
on   error   resume   next
rshgl1.Open   sqlhgl1,conn,1
%>

------解决方案--------------------

------解决方案--------------------
<%
dim rshgr1
dim sqlhgr1
dim count_hgr

sqlhgr1= "select count(id) as hgrs1 from scores where language> =60 and grade= "&grade& " and class= "&banji& " " '查询语文成绩合格人数
on error resume next
rshgr1.Open sqlhgr1,conn,1
count_hgr=rs( "hgrs1 ")
%>

<%
dim rshgl1
dim sqlhgl1
dim count_sum

sqlhgl1= "select count(*) as zrsh from scores where grade= "&grade& " and class= "&banji& " " '查询总人数
on error resume next
rshgl1.Open sqlhgl1,conn,1
count_sum=rs( "zrsh ")
%>

<%
dim rate
rate=count_hgr/count_sum
rate=rate*100
rate=left(rate,instr(rate, ". ")-1)
rate=rate& "% "
response.write rate
%>
------解决方案--------------------
melodywithme()
rate=left(rate,instr(rate, ". ")-1)

------解决方案--------------------
<%
dim rs,jige,renshu,sqlhgr1
on error resume next
sqlhgr1= "select count(id) as hgrs1 from scores where language> =60 and grade= "&grade& " and class= "&banji& " " '查询语文成绩合格人数
rs.Open sqlhgr1,conn,1,1
jige=rs( "hgrs1 ")
rs.close
sqlhgl1= "select count(*) as zrsh from scores where grade= "&grade& " and class= "&banji& " " '查询总人数
rs.Open sqlhgl1,conn,1,1
renshu=rs( "zrsh ")
rs.close
set rs=nothing
Response.Write( "及格率为： "&FormatPercent(Cint(jige)/Cint(renshu))