‘壹’ sql查询选修了“大学英语”的学生姓名、学号、性别、专业和年龄,且按照年龄降序排序
select 姓名,学号,性别,专业,年龄
from table
where 选修课='大学英语'
order by 年龄 desc
‘贰’ 数据库中sql查询比英语系学生的平均年龄小的其他系的学生姓名,年龄,系部
select 学生姓名,年龄,系部 from
student where 系部<>'英语系' and
年龄<(select avg(年龄)from student where 系部='英语系')
‘叁’ sql问题,高悬赏
use EDUC
select Sno,Sname,DATEDIFF(year,Sbirthday,GETDATE()) as Age from student
select * from SC where degree between 70 and 80
select Sno,Sname,Ssex,Sbirthday from student where YEAR(sbirthday)=1983
select * from course where Cname in ('高等数学','C语言','大学英语')
select Cno,COUNT(*) as 及格人数 from SC where DEGREE>60 group by cno having COUNT(*) >=2
涉及到具体的列名,可能有点不一样,你自己注意下,语句是没问题的,我这边测试过了
‘肆’ sql学生查询问题!急,小难!
1.
select 学生.姓名,学生.学号,教师.编号 from 学生,教师,授课 where
授课.教师编号=教师.编号 and 授课.学生学号=学生.学号 and 授课.成绩<60 and 授课.课程名称='数据库原理'
2.
select 学生.学号,学生.姓名,学生.成绩 from 学生,授课 where 授课.课程名称='英语' and 学生.专业='计算机'
3.
select 学生.学号,学生.姓名 ,学生.专业 from 学生,教师,授课 where
授课.教师编号=教师.编号 and 授课.学生学号=学生.学号 and
教师.姓名='张三' and 学生.成绩>95
4.
update 教师 set 教师.所在部门='计算机' where 教师.编号=002
‘伍’ 关于access数据,以下三个SQL语句怎么写
--不给出表结构怎么写?
--1.
select学号as学生号码,姓名,年龄from学生表where年龄>25
--2.
select课程名称,挂科人数from(select课程名称,count(*)挂科人数from课程表where成绩<90groupby课程名称)awherea.挂科人数>2
--3.
select课程名称,count(*)优秀人数from课程表where课程名称='大学英语'and成绩>80and成绩<90groupby课程名称
‘陆’ 查询每个学生的各科成绩sql语句
1、查询每个学生的各科成绩sql语句:
select a.studentid,a.name,a.sex,v1.score as '语文',v2.score as '数学', v3.score as '英语',v4.score
as ‘哲学’, (v1.score+v2.score+v3.score+v4.score)/4 as ‘平均成绩’ from Stuednt a
left join
(select studentid,score from grade where cid=(select cid from course where cname='语文'))as v1
on a.studentid=v1.studentid
left join
(select studentid,score from grade where cid=(select cid from course where cname='数学'))as v2
on a.studentid=v2.studentid
left join
(select studentid,score from grade where cid=(select cid from course where cname='英语'))as v3
on a.studentid=v3.studentid
left join
(select studentid,score from grade where cid=(select cid from course where cname='哲学'))as v4
on a.studentid=v4.studentid
order by a.studentid
2、sql数据库介绍:
(1)SQL是Structured Query Language(结构化查询语言)的缩写。SQL是专为数据库而建立的操作命令集,是一种功能齐全的数据库语言。在使用它时,只需要发出"做什么"的命令,"怎么做"是不用使用者考虑的。
(2)SQL功能强大、简单易学、使用方便,已经成为了数据库操作的基础,并且现在几乎所有的数据库均支持SQL。
(3)SQL数据库的数据体系结构基本上是三级结构,但使用术语与传统关系模型术语不同。
(4)在SQL中,关系模式(模式)称为"基本表"(base table);存储模式(内模式)称为"存储文件"(stored file);子模式(外模式)称为"视图"(view);元组称为"行"(row);属性称为"列"(column)。
‘柒’ SQL查询所以选修英语的学生姓名
SELECT Sname
FROM Student
WHERE (EXISTS
(SELECT 1
FROM SC INNER JOIN
Course ON SC.Cno = Course.Cno
WHERE (SC.Sno = Student.Sno) AND (Course.Cname = '英语')))
‘捌’ 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
‘玖’ access用一个sql表达某一个课程的参加总人数及平均分
select 课程名称,count(*),avg(成绩)
from a where 学号 like '19%' and 课程名称=‘大学英语’group by 课程名称;
‘拾’ 检索选修大学英语的学生名单和成绩,成绩高到低排,求改正!
没仔细看你的CREATE,只看了最后的查询语句,一眼就可以看出来,你的ORDER BY没有任何用处。
你可以这样想,SQL查询是随机的,那么你先排序,然后在外层又SELECT一遍,岂不是排好的数据又被随机打乱了?所以,ORDER BY一定是最外层的!