现有学生关系表S(sno,sname,ssex,sage),查找所有男生和女生的平均年龄信息,对应的SQL语句是________。
A. select ssex, avg(sage) fromS where ssex in('男', '女');
B. select ssex, avg(sage) fromS group by ssex;
C. select ssex, avg(sage) fromS;
D. select ssex, avg(distinct sage) fromS group by ssex;
查看答案
在学生关系表S(sno,sname,ssex,sage)上查找各年龄段的学生人数,显示总人数在10人以上的年龄段并按人数多少降序排列,对应的SQL语句是________。
A. select sage, count(*) from S where count(*)>10 group by sage order by count(*) DESC;
B. selectsage,count(*)人数fromSwheresum(*)>10orderby人数DESC;
C. selectsage,count(*)人数fromSgroupbysagehavingsum(*)>10orderby人数DESC;
D. selectsage,count(*)人数fromSgroupbysagehavingcount(*)>10orderby人数DESC;
现有学生关系表S(sno,sname,ssex,sage),查找年龄大于20岁的男生和女生人数信息,对应的SQL语句是________。
A. selectssex,count(*)fromSwheresage>20;
B. selectssex,count(*)fromSgroupbyssexhavingsage>20;
C. selectssex,count(*)fromSwheresage>20groupbyssex;
D. selectssex,count(*)fromSwheresage>20groupbyssex having sage>20;
现有学生关系表S(sno,sname,ssex,sage),查找年龄为20或21或22岁的男生信息的SQL语句是________。
A. select*fromSwheressex='男'and(sage=20orsage=21orsage=22);
B. select*fromSwheressex='男'andsage>=20andsage<=22;
C. select*fromSwheressex='男'and(sagebetween20and22);
D. select*fromSwheressex='男'andsagein(20,21,22);
现有学生关系表S(sno,sname,ssex,sage),查找所有姓名不是'张衡'的学生信息,并将结果按学号升序排列,下列选项中SQL语句正确的是________。
A. select*fromSwheresname!='张衡'orderbysno;
B. select*fromSwheresname<>'张衡'orderbysno;
C. select*fromSwheresname<>'张衡'orderbysnoASC;
D. select*fromSwheresname!='张衡'orderbysnoDESC;