access 查询百分比
来源:百度知道 编辑:UC知道 时间:2024/05/27 16:17:44
谢谢
哦,错了,我说的意思是字段为 “A”里面不一定就是A和b 还有其他的数值,我想知道他们各项数值个是多少,所占比例是多少?
A是多少
select A from biao1 where A='a'
B是多少
select A from biao1 where A='b'
至于所在百分比
建议先查出总数 select A from biao1
然后select A from biao1 where A='a'
两个再除一下
刚才我试了试直接用一条语句写,可是所得除数是零,但用加法算却是对的
你参考一下
select (select A from biao1 where A='a') / (select A from biao1 ) as bai
from biao
注:表为任意表,有一条记录即可
select A/B as 比率,A,B from 表1
select (select count(A) from t2 where A='aa')/(select count(A) from t2) as Arate, (select count(A) from t2 where A='bb')/(select count(A) from t2) as Brate, max(A) as name from t2 group by A
其中 A 为 表t2中的字段, aa,bb为表中的数据(文本型)
t2:
--------|
A |
--------|
aa |
--------|
bb |
--------|
aa |
--------|
<%
str="DBQ="+server.mappath("data/数据库名称.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=ser