我的表构造student_info | id |name |profession|score| |--|--|--|--| |id|姓名|分数|专业|
以上就是mysql实现每个专业分数段统计人数的具体内容
400到500人数,300到400人数select count(case when score between 400 and 500 then 1 end) as 400到500, count(case when score between 300 and 400 then 1 end) as 300到400 from student_info;
按分数段统计
按分数段和专业统计
400到500人数,300到400人数select count(case when score between 400 and 500 then 1 end) as 400到500, count(case when score between 300 and 400 then 1 end) as 300到400 from student_info GROUP BY profession;
sql动态拼接生成int start = 200; int end = 700; int inter = 10; int count = (end-start)/inter; StringBuilder sqlBuilder = new StringBuilder(); sqlBuilder.append("select "); for(int i =1;i<=count;i++){ int next = start+inter-1; Syste