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
复制代码
作者: 红鹰(Jake) 时间: 2013-12-29 12:55
1、执行创建表出现错误用这个语句是错误的:creat table T_Srouce,这样并没有指出表的创建结构,错误:1、关键字creat错误,应该create ,2、name后用“,”不是“."
正确如下:create table T_Srouce
(id varchar(6) primary key,name varchar(8),classname varchar(10),srouce int)
go
(
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)
)
2、select id,srouce from T_Srouce where srouce>=80 and srouce <=90执行结果:
id srouce
2001 85
2002 85
2003 85
2004 85
2005 85
2006 85
2007 85
2008 85
3、select AVG( math) from T_Srouce 执行结果:消息 207,级别 16,状态 1,第 1 行
列名 'math' 无效。
正确执行语句:select AVG(srouce) from T_Srouce where classname='math'
结果:
(无列名)
85
4、select * from T_Srouce where id like'张%' 查询不到数据
题目为:查询所有姓“张”的学生学号
正确语句:select id,name from T_Srouce where name like '张%'
结果:
不客气,我也是菜鸟。
共同学习吧作者: y494890511 时间: 2013-12-29 13:37
1.你是创建表呢?还是插入数据呢?
2.语法错误creat table T_Source创建表的
3.insert into T_Source(id,name,classname,srouce)values(2001,'张三','math',85)插入数据.
4.第一题:
(1).新建一个成绩表,包含:学号,姓名,课程名称,分数。通过Insert 插入初始化数据
(2).查找>=80分并且<=90分的学生学号和分数
(3).查找所有学生课程为“数学”的平均分
(4).查询所有姓“张”的学生学号
(1).create table T_Source
(
id varchar(6) primary key,
name varchar(8),
classname varchar(10),
srouce int
)
insert into T_Source(id,name.classname,source)values(2001,'张三','math',85)
insert into T_Source(id,name.classname,source)values(2002,'李四','math',85)
insert into T_Source(id,name.classname,source)values(2003,'王五','chinese',85)
insert into T_Source(id,name.classname,source)values(2004,'马六','math',85)
insert into T_Source(id,name.classname,source)values(2005,'赵七','chinese',85)
insert into T_Source(id,name.classname,source) values(2006,'陈春生','math',85)
insert into T_Source(id,name.classname,source) values(2007,'杨家将','english',85)
insert into T_Source(id,name.classname,source) values(2008,'张万里','english',85)
(2).select id,source from T_Source where srouce>=80 and srouce <=90
(3).select AVG( source) from T_Source where classname=math
(4).select id from T_Source where name like '张%'
(5).查询工资高于5000的员工,并按照年龄从低到高排列
select * from T_Personnel where salary>5000 order by age
(6).将所有工资低于3000的员工增加200元,工资>=3000,<=5000的增加100元
select name,age,sex,height,salary+200 from T_Personnel
where salary not exists(select salary+100 from Personnel where salary between 3000 and 5000)