select 编号,(数学+语文+英语)/3.0 as 平均成绩 from 表 order by 编号

解决方案 »

  1.   

    create table tb(编号 varchar(10),数学 int,语文 int,英语 int)
    insert into tb values('01',    85,     95,     82)
    insert into tb values('02',    87,     80,     80)
    goselect 编号,cast(cast(数学+语文+英语 as decimal(18,1))/3 as decimal(18,1)) 平均成绩 from tb order by 编号drop table tb/*
    编号       平均成绩                 
    ---------- -------------------- 
    01         87.3
    02         82.3
    (所影响的行数为 2 行)
    */