从sc表中求出学好为s1的同学的平均成绩,如果此平均成绩大于60则输出“pass”?
if (select avg(score) from sc where sno = 's1' group by sno)>60
begin
print 'pass'
end
//
笔记:
//创建此数据库
create database stuscore
go
use stuscore
go
//创建数据表
create table sc(
stuid nvarchar(10) not null primary key,
stuname nvarchar(10) not null,
score nvarchar(3) not null
)
//数据score计划错误,插入另一个成绩并且修改此属性
alter table sc
add scoremath nvarchar(3) not null
use stuscore
go
//修改属性
exec sp_rename 'sc.score','scoreenglish'
go
//插入表中信息
insert into sc(stuid,stuname,scoreenglish,scoremath) values(2009013711,'张倩',38,48)
insert into sc(stuid,stuname,scoreenglish,scoremath) values(2009013712,'少则',38,75)
insert into sc(stuid,stuname,scoreenglish,scoremath) values(2009013715,'王易',73,62)
----------------------------------------------------------------
//表中信息‘少则’计划出错,修改之
use stuscore
go
select*from sc where stuname = '少则'
go
update sc set scoreenglish = '38' where scoreenglish = '48'*stuname = '少则'
go
nowloading nowloading nowloading nowloading nowloading nowloading
if (select avg(score) from sc where sno = 's1' group by sno)>60
begin
print 'pass'
end
//
笔记:
//创建此数据库
create database stuscore
go
use stuscore
go
//创建数据表
create table sc(
stuid nvarchar(10) not null primary key,
stuname nvarchar(10) not null,
score nvarchar(3) not null
)
//数据score计划错误,插入另一个成绩并且修改此属性
alter table sc
add scoremath nvarchar(3) not null
use stuscore
go
//修改属性
exec sp_rename 'sc.score','scoreenglish'
go
//插入表中信息
insert into sc(stuid,stuname,scoreenglish,scoremath) values(2009013711,'张倩',38,48)
insert into sc(stuid,stuname,scoreenglish,scoremath) values(2009013712,'少则',38,75)
insert into sc(stuid,stuname,scoreenglish,scoremath) values(2009013715,'王易',73,62)
----------------------------------------------------------------
//表中信息‘少则’计划出错,修改之
use stuscore
go
select*from sc where stuname = '少则'
go
update sc set scoreenglish = '38' where scoreenglish = '48'*stuname = '少则'
go
nowloading nowloading nowloading nowloading nowloading nowloading