当前位置:首页 » 数据仓库 » 数据库删除选修大学英语的学生
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

数据库删除选修大学英语的学生

发布时间: 2022-07-09 10:26:09

sql数据库的查询怎么写呀帮帮忙拜托~

--1列出不及格记录的学生名单
select distinct student.snum,sname
from sc,student
where sc.snum=student.snum and score<60

--2列出选修了计算机系课程的学生姓名和年龄(表中只有出生年月)
select student.sname,(year(getdate())-year(birthday ))as age
from student
where snum in
(
select sc.snum
from sc,course,[section]
where sc.secnum=[section].secnum and course.cnum=[section].cnum and course.dept='计算机系'
)

--3检索选修了数据库技术课程的学生姓名和系别
select student.sname,student.dept
from student
where student.snum in
(
select snum
from sc,[section],course
where sc.secnum=[section].secnum and course.cnum=[section].cnum
and cname='数据库技术'
)

--4列出选修了所有课程的学生名单
select * from student
where not exists
(
select * from course
where not exists
(
select * from sc,section
where sc.secnum=section.secnum and student.snum=sc.snum
)
)

--5检索每门课程成绩都在80分以上的学生名单
select * from student
where snum in
(
select snum
from sc
group by snum
having min(score)>=80
)
--6检索获奖学金的学生 名单(每门课程在80分以上,平均成绩在90分以上)
select * from student
where snum in
(
select snum
from sc
group by snum
having min(score)>=80 and avg(score)>=90
)
--7检索选修了大学英语的学生名单和成绩,并按成绩从高到低排列
select student.snum,student.sname,sc.score
from sc,student
where student.snum in
(
select snum from sc,section,course
where sc.secnum=section.secnum and course.cnum=section.cnum and cname='大学英语'
)
order by score desc

--8统计每门课程的选修人数,输出列明为课程号,人数
select cnum as 课程号,count(*) 人数
from section,sc
where section.secnum=sc.secnum
group by cnum
--9查询选修了数据库技术,没有选修高等数学的学生姓名和系别
select student.sname,student.dept
from student
where student.snum in
(
select distinct snum from sc,section,course
where sc.secnum=section.secnum and section.cnum=course.cnum and course.cname='大学英语'
)
and student.snum not in
(
select distinct snum from sc,section,course
where sc.secnum=section.secnum and section.cnum=course.cnum and course.cname='高等数学'
)
--11统计每门课程的选课人数及不及格人数
select cnum,count(*) as 选课人数, case when
(
select count(*) from sc,section
where sc.secnum=section.secnum and score<60
group by cnum
) is NULL then 0 else (
select count(*) from sc,section
where sc.secnum=section.secnum and score<60
group by cnum
) end as 不及格人数
from sc,section
where sc.secnum=section.secnum
group by section.cnum

Ⅱ 使用SQL语句删除没有学生选修的课程记录

1、第一步,创建学生和课程,详细代码见下图,转到下面的步骤。

Ⅲ 检索选修大学英语的学生名单和成绩,成绩高到低排,求改正!

没仔细看你的CREATE,只看了最后的查询语句,一眼就可以看出来,你的ORDER BY没有任何用处。
你可以这样想,SQL查询是随机的,那么你先排序,然后在外层又SELECT一遍,岂不是排好的数据又被随机打乱了?所以,ORDER BY一定是最外层的!

Ⅳ 删除选修了英语课的学生的成绩信息sql语言

deletefrom成绩表where课程号in(select课程号from课程表where课程名称='英语')

Ⅳ 数据库学生信息表如何删除某个同学的记录信息

对于数据库表来说,不会做删除操作的,这样其实不太安全,学生信息表应该有一列是状态,改成无效或退学,然后会有一张记录这种信息的表,把这个同学的退学日期,原因,经手人等等信息新增上去。

Ⅵ 数据库中现有学生表,选课表,成绩表,怎么删除大于18岁学生的所有选课信息

假设这3个表的结构如下:
学生表(学号,姓名,年龄,出生日期)
选课表(学号,课程号,课程名称)
成绩表(学号,课程号,成绩)

以上述表结构为前提,T-SQL语句如下:
delete 成绩表 where 学号 in (select 学号 from 学生表 where 年龄>18)
delete 选课表 where 学号 in (select 学号 from 学生表 where 年龄>18)

如果学生表中没有‘年龄’字段,只有‘出生日期’字段的话,T-SQL语句如下:
delete 成绩表 where 学号 in (select 学号 from 学生表 where datediff(yy,出生日期,getdate())>18)
delete 选课表 where 学号 in (select 学号 from 学生表 where datediff(yy,出生日期,getdate())>18)

Ⅶ 如何删除一个数据库中某个学生的全部记录

例如你有一个学生表student 你要删除表格里面的一个叫刘慧同学的信息
你就应该敲 delete * from student where name = ‘刘慧’(方法:delete from <数据表> where 学号='学生的学号')

Ⅷ 数据库:在选修课中删除选修了授课班号为'246403'这门课程的学生信息

--楼主既然筛选的是授课班号 那就写授课班号了
--不明白可以随时问我 希望采纳
--如果你删除的是关联的表 也就是说不是此表的话 就得写个链接 或者子查询也可以
Delete 学生选课表 where 授课班号=‘246403’

--如果你删除的是学生表的内容的话

delete 学生表 where xh in(select xh from 学生选课表 where 授课班号=‘246403’)