有一个数据表user,里面有字段jibie(分1、2、3、4、5).那我要分别统计出jibie为1、2、3、4、5的会员数量。
但是我不知道怎么写,希望高手能帮忙!
怎么把统计结果显示出来呢?
数据分类统计 asp
答案:2 悬赏:0 手机版
解决时间 2021-03-22 01:44
- 提问者网友:椧運幽默
- 2021-03-21 06:58
最佳答案
- 五星知识达人网友:夜余生
- 2021-03-21 07:18
select count(jibie) from user group by jibie
补充:
显示?你是指用 ADO RecordSet 吧,加个别名。另外 user 可能是保留字,扩起来
select count(jibie) as jibies from [user] group by jibie
要统计各级别这样做
select count(jibie) as count1 from [user] where jibie = 1
select count(jibie) as count1 from [user] where jibie = 2
...
或者
select count(jibie) as count1 from [user] group by jibie order by jibie
......
for i= 1 to rs.recordsetcount
response.write "等级" & i & ":" & & rs("count1")
rs.movenext
next
补充:
显示?你是指用 ADO RecordSet 吧,加个别名。另外 user 可能是保留字,扩起来
select count(jibie) as jibies from [user] group by jibie
要统计各级别这样做
select count(jibie) as count1 from [user] where jibie = 1
select count(jibie) as count1 from [user] where jibie = 2
...
或者
select count(jibie) as count1 from [user] group by jibie order by jibie
......
for i= 1 to rs.recordsetcount
response.write "等级" & i & ":" & & rs("count1")
rs.movenext
next
全部回答
- 1楼网友:猎心人
- 2021-03-21 08:07
给你个思路吧:
1、查询表把字段(dian)的各种值(去重)的记录取出;
涉及语句 sql ="select distinct dian from tablename where......"
2、循环输出每种值得记录的统计信息
涉及语句 sql = "select count(*)as count from tablename group by dian where dian = '上一条语句查出的值';"
在循环中分别查询的统计数字给予输出
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯