有一个考生成绩的数据库,这么把成绩按10分一个分段导出考生的成绩数据

解决方案 »

  1.   

    Create Table Test
    (
    srocl int,
    id int
    )
    Go
    insert into Test
    select 50,1 union all
    select 55,2 union all
    select 63,3 union all
    select 77,4 union all
    select 78,5 union all
    select 80,6 union all
    select 88,7 union all
    select 92,8 union all
    select 100,9 union all
    select 94,10select id,srocl,case 
    when srocl>=50 and srocl<60 then '差' 
    when srocl>=60 and srocl<70 then '較差'
    when srocl>=70 and srocl<80 then '一般' 
    when srocl>=80 and srocl<90 then '較好'
    when srocl>=90 and srocl<100 then '優秀'
    when srocl =100 then '非常優秀'
    end as srcol
    from TEST
    order by srocl asc