SQL code:
use tempdb
if object_id('t') is not null drop table t
go
create table t([Sno] varchar(50),[Cno] INT,[Grade] INT)
insert into t
select '95001',1,92 union all
select '95001',2,85 union all
select '95001',3,88 union all
select '95001',4,23 union all
select '95001',5,34 union all
select '95001',6,56 union all
select '95001',7,86 union all
select '95001',8,88 union all
select '95002',2,90 union all
select '95002',3,80 union all
select '95003',1,50 union all
select '95003',3,98 union all
select '95005',3,NULL
go
select * from t
查询 至少选修了[学生95002选修全部课程]的学生号码
SQL code:
select sno from sc
where cno in (select cno from sc where sno = '95002')
and sno <> '95002'
group by sno
having count(*) = (select count(*) from sc where sno = '95002')
这是我的查询,学习高手高效的写法
我这个好像也不怎么快,呵呵
SQL code:
use tempdb
if object_id('t') is not null drop table t
go
create table t([Sno] varchar(50),[Cno] INT,[Grade] INT)
insert into t
select '95001',1,92 union all
select '95001',2,85 union all
select '95001',3,88 union a
可能因为工作的原因 接触数据库这块比较少,之前都是做程序这块,数据库这块都有专门的人来做 分工都很明细 所以对数据库这一块完全不了解。前段时间 去面试了几家公司 几乎都是在数据库这块挂掉的 连个简单的SQ ......