- 论坛徽章:
- 0
|
declare@tb table(cNum varchar(4), fMath float, fChinese float)
insert into @tb values(\'0001\', 98,88)
insert into @tb values(\'0002\', 80,20)
insert into @tb values(\'0003\', 78,76)
insert into @tb values(\'0004\', 90,66)
insert into @tb values(\'0005\', 82,62)
insert into @tb values(\'0006\', 62,56)
insert into @tb values(\'0007\', 57,55)
--统计数学成绩区间
select
Math,
count_math = Count(cNum)
from
(select
cNum,
Math = (case when isnull(fMath,0)>=0 and isnull(fMath,0)=60 and isnull(fMath,0)=75 and isnull(fMath,0)=85 and isnull(fMath,0)=0 and isnull(fChinese,0)=60 and isnull(fChinese,0)=75 and isnull(fChinese,0)=85 and isnull(fChinese,0)<=100 then \'[85,100]\'
else \'error value\'
end)
from
@tb
) as a
group by
Chinese
order by
Chinese
|
|