一.SQL语言查询选修了全部课程的学生的学号和姓名. 两种解决途径: 第一种: 我们可以表示为在SC表中某个学生选修的课程数等于C表中课程总数.相应的SQL语言如下: select S#,SNAME from S where S# in (select S# from SC group by S# --根据Sno分组,统计每个学生选修了几门课程.如果等于C表课程的总数,就是我们要找的S# having count(*) = (select count(*) from C))--统计C表中共有几门
select sname from student where not exists (select * from course where not exists (select * from sc where sno =student.sno and cno=course.cno); 最内部的 select * from sc where sno=student.sno and cno = course.cno是查询出所有已经选择过课程的学生及相应课程,select * from cour
SELECT表名=case when a.colorder=1 then d.name else '' end,--表说明=case when a.colorder=1 then isnull(f.value,'') else '' end,--字段序号=a.colorder,字段名=a.name,标识=case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '√'else '' end,主键=case when exists(SEL
---正在执行的 select a.username, a.sid,b.SQL_TEXT, b.SQL_FULLTEXT from v$session a, v$sqlarea b where a.sql_address = b.address ---执行过的 select b.SQL_TEXT,b.FIRST_LOAD_TIME,b.SQL_FULLTEXT from v$sqlarea b where b.FIRST_LOAD_TIME between '2009-10-15/09:24:4
---正在执行的select a.username, a.sid,b.SQL_TEXT, b.SQL_FULLTEXT from v$session a, v$sqlarea b where a.sql_address = b.address ---执行过的select b.SQL_TEXT,b.FIRST_LOAD_TIME,b.SQL_FULLTEXT from v$sqlarea bwhere b.FIRST_LOAD_TIME between '2009-10-15/09:24:47
每年 select to_char(createtime, 'YYYY') 年, count(*) from table group by to_char(createtime, 'YYYY'); 每季度 select to_char(createtime, 'q') 年, count(*) from table group by to_char(createtime, 'q'); 每月 select to_char(createtime, 'YYYY') 年, to_char(create
1.相关数据表 Score表 [User]表 SQL语句例如以下: --查询出各科成绩最好的学生信息 --自连接 --SELECT TOP 1 * FROM Score B WHERE B.ScoreName = '数学' ORDER BY B.Score DESC SELECT A.ID,U.Name,A.ScoreName,A.Score FROM Score A,[User]U WHERE UID IN (SELECT TOP 1 UID FR
前几天求职面试,有一道SQL题:给出三个表:学生.课程.成绩,求选修了所有课程的学生. 一道看似很简单的问题,把我难住了,我改了又改,涂涂画画,抓耳挠腮,因为试卷没有多少空白位置了,最后只好放弃.心情大受影响,尽管最后还是获得offer. 但是心中有愧呀! 于是在机器上试了试: 先建好表 use test; go create table student(sno varchar(50) not null,name varchar(50) not null); insert into studen