根据SQL标准,要查询表student中平均年龄age小于21的所在系dept及其平均年龄值,下面哪条语句适用?()
A select dept,avg(age) from student where avg(age)<21
B select dept,avg(age) from student group by dept having avg(age)<21
C select dept,avg(age) from student having avg(age)<21
D select dept,avg(age) from student group by dept where avg(age)<21
第1题:
根据SQL标准,创建一个视图abc,通过该视图只能对表student中系dept为‘IS’的记录进行更新操作。下面哪条语句适用?()
A create view abc as select * from student where dept=’IS’
B create view abc as select * from student where dept=’IS’ with check option
C create view abc as student where dept=’IS’
D create view abc as select dept=’IS’ from student
第2题:
根据SQL标准,查询表student(sno,sname,sex,dept)中所有学生的选修课程数,其中选修记录在表SC(sno,cno,grade)中,两表中sno为关联字段。下面哪条语句合适?()
A select sno,count(cno) from SC
B select sno,count(cno) from student
C select a.sno,count(cno) from student a left outer join SC
D select a.sno,count(cno) from SC left outer join student a
第3题:
现有雇员表,结构为:雇员表(雇员号,姓名,所在部门,年龄) 现要统计每个部门的雇员的平均年龄,希望查询结果是按平均年龄从高到低的顺序排列,并且只取平均年龄最高的前3个部门。完成此功能的查询语句为()
A.SELECT TOP 3 WITH TIES 所在部门,AVG(年龄) 平均年龄 FROM 雇员表 ORDER BY 平均年龄 desc
B.SELECT TOP 3 WITH TIES 所在部门,AVG(年龄) 平均年龄 FROM 雇员表 GROUP BY 所在部门
C.SELECT TOP 3 WITH TIES 所在部门,AVG(年龄) 平均年龄 FROM 雇员表 GROUP BY 所在部门 ORDER BY 平均年龄
D.SELECT TOP 3 WITH TIES 所在部门,AVG(年龄) 平均年龄 FROM 雇员表 GROUP BY 所在部门 ORDER BY 平均年龄 DESC
第4题:
根据SQL标准,下面哪句语句能够找出年龄最小的同学?其中age为学生表student中的年龄字段,sno为学生的学号。()
A select max(age) from student
B select sno from student where age = max(age)
C select sno from student having age = max(age)
D select sno from student a where a.age<= (select min(b.age) from student b)
第5题:
根据SQL标准,要查询表student中所有年龄age小于所有学生的平均年龄的记录,下面哪条语句适用?()
A select * from student where age< avg(age)
B select * from student having age< avg(age)
C select * from student a where a.age< (select avg(b.age) from student b)
D select * from student a where (select avg(b.age) from student b ) >= a.age