统计各系男生人数,最准确的SQL语句是(
)。
A: SELECT
COUNT(*) FROM stduents GROUP BY d_no WHERE sex='男'
B: SELECT
COUNT(*) FROM students WHERE sex='男'
GROUP BY d_no
C: SELECT
COUNT(*) FROM students WHERE sex='男'
ORDER BY d_no
D: SELECT
COUNT(*) FROM students HAVING sex='男'
GROUP BY d_no
)。
A: SELECT
COUNT(*) FROM stduents GROUP BY d_no WHERE sex='男'
B: SELECT
COUNT(*) FROM students WHERE sex='男'
GROUP BY d_no
C: SELECT
COUNT(*) FROM students WHERE sex='男'
ORDER BY d_no
D: SELECT
COUNT(*) FROM students HAVING sex='男'
GROUP BY d_no
举一反三
- 查询姓王的学生信息,最准确的SQL语句是(<br/>)。 A: SELECT<br/>* FROM students WHERE s_name='王' B: SELECT<br/>* FROM students WHERE s_name='王%' C: SELECT<br/>* FROM students WHERE s_name LIKE '王' D: SELECT<br/>* FROM students WHERE s_name LIKE '王%'
- 列出所有部门的部门名称和部门员工人数。如果部门没有员工,人数显示为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
- 下面 语句和”select * from student where sex=’男’ && age=20;”语句查询出的结果是一样的。( ) A: select * from student where sex=’男’ or age=20; B: select * from student where sex=’男’ || age=20; C: select * from student where sex=’男’ and age=20; D: select * from student where sex,age in(’男’,20);
- 设有关系S(S#,SNAME,AGE,SEX)、C(C#,CNAME,TEACHER)和SC(S#,C#,GRADE),请将实现以下功能的SQL语句填写完整:[br][/br] (4)检索全部学生都选修的课程的课程号(C#)和课程名(CNAME)。 [br][/br] 方法1: SELECT C#,CNAME FROM C WHERE (SELECT * FROM S WHERE (SELECT * FROM SC WHERE C.C#=SC.C# AND S.S#=SC.S#)) 方法2: select c#,cname from c where c# in( select c# from sc group by having count(distinct s#)=(select count(*) from ))
- 查询在2009年9月出生的学生,最准确的SQL语句是(<br/>)。 A: SELECT<br/>* FROM students WHERE birthday BETWEEN '2009-09-01' AND '2009-09-30' B: SELECT<br/>* FROM students WHERE birthday BETWEEN 2009-09-01 AND 2009-09-30 C: SELECT<br/>* FROM students WHERE birthday BETWEEN '2009-09-01' AND '2009-09-31' D: SELECT<br/>* FROM students WHERE birthday BETWEEN 2009-09-01 AND 2009-09-31