作者bluehaerts (5858笨58)
看板Database
标题Re: [MYSQL ] 分数统计 是用COUNT吗
时间Tue Jun 16 14:29:05 2009
※ 引述《bluehaerts (5858笨58)》之铭言:
: table a
: class_id score
: c01 100
: c01 80
: c01 70
: c01 85
: c01 88
: c01 75
: c01 70
: 我用 select count(score)
: from a
: where '8%'
: 可是这样不行耶 请问我是哪边需要修改阿
谢谢各位高手的回答
SELECT COUNT(score)
FROM class_s
where score BETWEEN '80' AND '89' and class_id = 'c01 '
我已经会把80-89分的资料抓出来了
现在我重点是 我要怎麽下GROUP BY 的指令
因为我想 每10分当1个区间 抓出资料有几笔
SELECT FLOOR(score/10),COUNT(FLOOR(score/10))
FROM class_s
where cid = 'c01 '
group by FLOOR(score/10)
恩 我去找了FLOOR来用 就可以了
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.134.140.40
1F:推 kylekai:除以10就好了 06/16 14:55
2F:→ bluehaerts:请问一下 哪边除以10 SCORE 我除过不能 06/16 15:08
※ 编辑: bluehaerts 来自: 140.134.140.40 (06/16 15:33)