数据库设计:
第一种方法:
select count(if(score between 0 and 60,true,null))as "0~60",
count(if(score between 60 and 80,true,null)) as "60~80",
count(if(score between 80 and 100,true,null)) as "80~100"
from ques where dish_id=1
第二种方法:
select sum(if(score<60,1,0)) as '<60',
sum(if(score between 60 and 80,1,0)) as '60~80',
sum(if(score>80,1,0)) as '>80'
from ques where dish_id=1