有一张学生考核表,表结构如下所示:
create table studentValue
(
学号 varchar(10),
姓名 varchar(10),
品德考核分值 tinyint,
学习考核分值 tinyint,
体育考核分值 tinyint,
总考核分值  tinyint
)
表内容如下所示:
学号 姓名  品德考核分值 学习成绩考核分值 体育考核分值 总考核分值
001 王波  0           0              0           90
002 张三  0           0              0           82  
003 李四  0           0              0           76   
说明:
学生的总考核分值满分为100,在上述的表中已知学生的总考核分值,如何随机地分配各考核内容的分值.
注意:各考核内容的比值不一样,我们约定品德考核分值占30%,学习成绩考核分值占50%,体育考核分值占20%

解决方案 »

  1.   

    update studentValue set 品德考核分值=总考核分值*0.3,学习成绩考核分值=总考核分值*0.5, 体育考核分值=总考核分值*0.2
      

  2.   

    update studentValue set 品德考核分值=总考核分值*0.3,学习成绩考核分值=总考核分值*0.5, 体育考核分值=总考核分值*0.2
      

  3.   

    create table studentValue 

    学号 varchar(10), 
    姓名 varchar(10), 
    品德考核分值 tinyint, 
    学习考核分值 tinyint, 
    体育考核分值 tinyint, 
    总考核分值  tinyint 

    insert studentValue select '001','王波',0,0,0,90
    insert studentValue select '002','张三',0,0,0,82
    insert studentValue select '003','李四',0,0,0,76
    update studentValue set 品德考核分值=总考核分值*0.3,学习考核分值=总考核分值*0.5, 体育考核分值=总考核分值*0.2select * from studentValue学号         姓名         品德考核分值 学习考核分值 体育考核分值 总考核分值
    ---------- ---------- ------ ------ ------ -----
    001        王波         27     45     18     90
    002        张三         24     41     16     82
    003        李四         22     38     15     76(3 行受影响)
      

  4.   


    update studentValue set 品德考核分值=总考核分值*0.3,学习成绩考核分值=总考核分值*0.5, 体育考核分值=总考核分值*0.2
      

  5.   

    create table studentValue 

    学号 varchar(10), 
    姓名 varchar(10), 
    品德考核分值 tinyint, 
    学习考核分值 tinyint, 
    体育考核分值 tinyint, 
    总考核分值  tinyint 

    insert studentValue select '001','王波',0,0,0,90
    insert studentValue select '002','张三',0,0,0,82
    insert studentValue select '003','李四',0,0,0,76
    update studentValue set 品德考核分值=round(总考核分值*0.3,0),学习考核分值=round(总考核分值*0.5,0), 体育考核分值=round(总考核分值*0.2,0)select * from studentValue学号         姓名         品德考核分值 学习考核分值 体育考核分值 总考核分值
    ---------- ---------- ------ ------ ------ -----
    001        王波         27     45     18     90
    002        张三         25     41     16     82
    003        李四         23     38     15     76(3 行受影响)应该这样才准确.