以下是引用schtg在2023-10-13 06:44:56的发言:
我的计算方法就是那么想就那么算,没有技巧可言哈,可能运算速度不快,以计算出最终结果为目的,纯业余爱好,水平有限
select czxxdm,count(*) as zrs,;
sum(iif(语文>=120,1,0)) as 优语文,round(sum(iif(语文>=120,1,0))/count(*)*100,2) as 优语文率,;
sum(iif(语文>=105 and 语文<120,1,0)) as 良语文,round(sum(iif(语文>=105 and 语文<120,1,0))/count(*)*100,2) as 良语文率,;
sum(iif(语文>=90 and 语文<105,1,0)) as 及语文,round(sum(iif(语文>=90 and 语文<105,1,0))/count(*)*100,2) as 及语文率, ;
sum(iif(数学>=120,1,0)) as 优数学,round(sum(iif(数学>=120,1,0))/count(*)*100,2) as 优数学率,;
sum(iif(数学>=105 and 数学<120,1,0)) as 良数学,round(sum(iif(数学>=105 and 数学<120,1,0))/count(*)*100,2) as 良数学率,;
sum(iif(数学>=90 and 数学<105,1,0)) as 及数学,round(sum(iif(数学>=90 and 数学<105,1,0))/count(*)*100,2) as 及数学率, ;
sum(iif(英语>=120,1,0)) as 优英语,round(sum(iif(英语>=120,1,0))/count(*)*100,2) as 优英语率,;
sum(iif(英语>=105 and 英语<120,1,0)) as 良英语,round(sum(iif(英语>=105 and 英语<120,1,0))/count(*)*100,2) as 良英语率,;
sum(iif(英语>=90 and 英语<105,1,0)) as 及英语,round(sum(iif(英语>=90 and 英语<105,1,0))/count(*)*100,2) as 及英语率, ;
sum(iif(物理>=80,1,0)) as 优物理,round(sum(iif(物理>=80,1,0))/count(*)*100,2) as 优物理率,;
sum(iif(物理>=70 and 物理<80,1,0)) as 良物理,round(sum(iif(物理>=70 and 物理<80,1,0))/count(*)*100,2) as 良物理率,;
sum(iif(物理>=60 and 物理<70,1,0)) as 及物理,round(sum(iif(物理>=60 and 物理<70,1,0))/count(*)*100,2) as 及物理率, ;
sum(iif(化学>=80,1,0)) as 优化学,round(sum(iif(化学>=80,1,0))/count(*)*100,2) as 优化学率,;
sum(iif(化学>=70 and 化学<80,1,0)) as 良化学,round(sum(iif(化学>=70 and 化学<80,1,0))/count(*)*100,2) as 良化学率,;
sum(iif(化学>=60 and 化学<70,1,0)) as 及化学,round(sum(iif(化学>=60 and 化学<70,1,0))/count(*)*100,2) as 及化学率, ;
sum(iif(生物>=80,1,0)) as 优生物,round(sum(iif(生物>=80,1,0))/count(*)*100,2) as 优生物率,;
sum(iif(生物>=70 and 生物<80,1,0)) as 良生物,round(sum(iif(生物>=70 and 生物<80,1,0))/count(*)*100,2) as 良生物率,;
sum(iif(生物>=60 and 生物<70,1,0)) as 及生物,round(sum(iif(生物>=60 and 生物<70,1,0))/count(*)*100,2) as 及生物率, ;
sum(iif(政治>=80,1,0)) as 优政治,round(sum(iif(政治>=80,1,0))/count(*)*100,2) as 优政治率,;
sum(iif(政治>=70 and 政治<80,1,0)) as 良政治,round(sum(iif(政治>=70 and 政治<80,1,0))/count(*)*100,2) as 良政治率,;
sum(iif(政治>=60 and 政治<70,1,0)) as 及政治,round(sum(iif(政治>=60 and 政治<70,1,0))/count(*)*100,2) as 及政治率, ;
sum(iif(历史>=80,1,0)) as 优历史,round(sum(iif(历史>=80,1,0))/count(*)*100,2) as 优历史率,;
sum(iif(历史>=70 and 历史<80,1,0)) as 良历史,round(sum(iif(历史>=70 and 历史<80,1,0))/count(*)*100,2) as 良历史率,;
sum(iif(历史>=60 and 历史<70,1,0)) as 及历史,round(sum(iif(历史>=60 and 历史<70,1,0))/count(*)*100,2) as 及历史率, ;
sum(iif(地理>=80,1,0)) as 优地理,round(sum(iif(地理>=80,1,0))/count(*)*100,2) as 优地理率,;
sum(iif(地理>=70 and 地理<80,1,0)) as 良地理,round(sum(iif(地理>=70 and 地理<80,1,0))/count(*)*100,2) as 良地理率,;
sum(iif(地理>=60 and 地理<70,1,0)) as 及地理,round(sum(iif(地理>=60 and 地理<70,1,0))/count(*)*100,2) as 及地理率 ;
from zcj group by czxxdm order by czxxdm