本帖最后由 qly2046 于 2013-12-29 22:10 编辑
由于本人电脑装不上SQL SERVER 2008,所以 在学习SQL课程的时候,只能在记事本里手写SQL练习代码!下面有两道题的代码,望好心人帮忙在SQL里面实现一下,并告知运行结果!谢谢大家了!一定要把错误指出来哦!
第一题:
1.新建一个成绩表,包含:学号,姓名,课程名称,分数。通过Insert 插入初始化数据
2、查找>=80分并且<=90分的学生学号和分数
3、查找所有学生课程为“数学”的平均分
4、查询所有姓“张”的学生学号- creat table T_Srouce
- (
- insert into T_Srouce(id,name.classname,srouce)values(2001,'张三','math',85)
- insert into T_Srouce(id,name.classname,srouce)values(2002,'李四','math',85)
- insert into T_Srouce(id,name.classname,srouce)values(2003,'王五','chinese',85)
- insert into T_Srouce(id,name.classname,srouce)values(2004,'马六','math',85)
- insert into T_Srouce(id,name.classname,srouce)values(2005,'赵七','chinese',85)
- insert into T_Srouce(id,name.classname,srouce)values(2006,'陈春生','math',85)
- insert into T_Srouce(id,name.classname,srouce)values(2007,'杨家将','english',85)
- insert into T_Srouce(id,name.classname,srouce)values(2008,'张万里','english',85)
- )
- select id,srouce from T_Srouce where srouce>=80 and srouce <=90
- select AVG( math) from T_Srouce
- select * from T_Srouce where id like'张%'
复制代码
第二题:
1、设计一张员工表,包含:姓名,年龄,性别,身高,工资等字段,通过Insert初始化
数据
2、查询姓“李”的员工个数
3、查询工资高于5000的员工,并按照年龄从低到高排列
4、将所有工资低于3000的员工增加200元,工资>=3000,<=5000的增加100元- creat table T_Personnel
- (
- insert into T_Personnel ( name,age,sex,height,salary) values ('张三',20,'男',180,4000)
- insert into T_Personnel ( name,age,sex,height,salary) values ('李四',30,'男',170,2000)
- insert into T_Personnel ( name,age,sex,height,salary) values ('王五',34,'男',186,3000)
- insert into T_Personnel ( name,age,sex,height,salary) values ('马六',58,'男',175,5000)
- insert into T_Personnel ( name,age,sex,height,salary) values ('赵七',40,'男',165,6000)
- insert into T_Personnel ( name,age,sex,height,salary) values ('龙八',43,'男',178,7000)
- insert into T_Personnel ( name,age,sex,height,salary) values ('刘德华',60,'男',190,2800)
- insert into T_Personnel ( name,age,sex,height,salary) values ('李世明',29,'男',150,3200)
- insert into T_Personnel ( name,age,sex,height,salary) values ('李传胜',53,'男',140,4100)
- )
- selset COUNT(*) from T_Personnel where name like '李%'
- select * from T_Personnel where salary>5000 order by age
- update salary+=200,salary+=100 T_Personnel where salary<3000 ,salary>=3000 and salary<=5000
复制代码
|