以下不能实现统计各个部门男教师的人数的命令是?
A: db.teachers.aggregate([{$match:{"sex":"男"}},{$group:{"_id":{"dept":"$dept"},"num_count":{$sum:1}}}])
B: db.teachers.aggregate([{$group:{"_id":{"dept":"$dept"},"num_count":{$sum:1}}},{$match:{"sex":"男"}}])
C: db.teachers.group({"key":{"dept":2},"initial":{"count":0},"reduce":function(cur,result){return result.count++},"cond":{"sex":"男"}})
D: db.teachers.runCommand({"group":{"ns":"teachers","key":{"dept":0},"initial":{"count":0},"$reduce": function(cur,result){result.count++;},"cond":{"sex":"男"}}})
A: db.teachers.aggregate([{$match:{"sex":"男"}},{$group:{"_id":{"dept":"$dept"},"num_count":{$sum:1}}}])
B: db.teachers.aggregate([{$group:{"_id":{"dept":"$dept"},"num_count":{$sum:1}}},{$match:{"sex":"男"}}])
C: db.teachers.group({"key":{"dept":2},"initial":{"count":0},"reduce":function(cur,result){return result.count++},"cond":{"sex":"男"}})
D: db.teachers.runCommand({"group":{"ns":"teachers","key":{"dept":0},"initial":{"count":0},"$reduce": function(cur,result){result.count++;},"cond":{"sex":"男"}}})
举一反三
- 统计各系男生人数,最准确的SQL语句是(<br/>)。 A: SELECT<br/>COUNT(*) FROM stduents GROUP BY d_no WHERE sex='男' B: SELECT<br/>COUNT(*) FROM students WHERE sex='男'<br/>GROUP BY d_no C: SELECT<br/>COUNT(*) FROM students WHERE sex='男'<br/>ORDER BY d_no D: SELECT<br/>COUNT(*) FROM students HAVING sex='男'<br/>GROUP BY d_no
- 列出所有部门的部门名称和部门员工人数。如果部门没有员工,人数显示为0。正确的查询语句有_________。 A: SELECT dname,COUNT(ename) AS ecount <br>FROM dept,emp <br>WHERE emp.deptno(+)=dept.deptno <br>GROUP BY dept.dname B: SELECT dname,(SELECT COUNT(*) AS ecount FROM emp WHERE emp.deptno=dept.deptno) <br>FROM dept C: SELECT dname,COUNT(ename) AS ecount <br>FROM dept LEFT JOIN emp ON emp.deptno=dept.deptno <br>GROUP BY dept.dname D: SELECT dname,COUNT(*) AS ecount <br>FROM dept LEFT JOIN emp ON emp.deptno=dept.deptno <br>GROUP BY dept.dname
- 统计每个部门中人数的语句是? A: select count(id) from emp order by deptno; B: select sum(id) from emp order by deptno; C: select count(id) from emp group by deptno; D: select sum(id) from emp group by deptno;
- 统计每个部门中的人数的语句是【】。 A: SELECT SUM(ID) FROM examp GROUP BY DE_NUM B: SELECT COUNT(ID) FROM examp ORDER BY DE_NUM C: SELECT COUNT(ID) FROM examp GROUP BY DE_NUM D: SELECT SUM(ID) FROM examp ORDER BY DE_NUM
- 3个表即学生表S、课程表C和学生选课表SC,它们的结构如下: S(S#,SN,SEX,AGE,DEPT)C(C#,CN)SC(S#,C#,GRADE)其中:S#为学号,SN为姓名,SEX为性别,AGE为年龄,DEPT为系别,C#为课程号,CN为课程名,GRADE为成绩。检索选修课程名称为“DB”的男生中的最高成绩,正确的SELECT语句是____。 A: SELECT MAX(GRADE) FROM SC WHERE CN='DB’ AND SEX='男' B: SELECT MAX(GRADE) FROM SC,C,SWHERE CN='DB' AND SEX='男' C: SELECT MAX(GRADE) FROM SC,S WHERE SC D: =C E: AND CN='DB' AND SEX='男' F: SELECT MAX(GRADE) FROM SC,C,SWHERE SC G: =C H: AND SS I: =S.S J: AND CN='DB' AND SEX='男'