没有试,不知道对不对,你试试看
1. select SC.S#, S.SN 
from S,C,SC 
where C.CN='税收基础' and
      C.C#=SC.C# and
  SC.S#=S.S#;2.select S.SN, S.SD
from S,SC 
where SC.C#='c2' and
  SC.S#=S.S#;3.select distinct S.SN, S.SD
from S,SC 
where SC.C#<>'c5' and
  SC.S#=S.S#;4.select distinct S.SN, S.SD, count(SC.C#), t.num
from S,C,SC,(select count(*) num from C) t
where SC.S#=S.S# and
      SC.C#=C.C#
having count(SC.C#)=t.num
group by S.SN, S.SD;5.select distinct S.SN, S.SD, max(rownum)
from S,SC 
where SC.S#=S.S#
group by S.SN, S.SD;6.select distinct S.SN, S.SD, count(SC.C#)
from S,C,SC
where SC.C#=C.C# and
  SC.S#=S.S#
having count(SC.C#)>5
group by S.SN, S.SD;

解决方案 »

  1.   

    1:
     select s#, sn from s 
     where s# in ( select s# from sc where c# in (select c# from c where cn='税收基础'))
    2:
     select sn, sd from s
     where s# in (select s# from sc where c# = 'c2')
    3:
     select sn, sd from s
     where s# not in (select s# from sc where c# = 'c5')4:这个没有试过对不对
     select sn, sd from s
     where (select count(*) from sc where s#=s.S#) =
           (select count(*) from c)
    5:
     select count(*) from s
     where ezists(select 1 from sc where s#=s.s#)
    6:
     select s#, sd from s
     where (select count(*) from sc where s#=s.s#) > 5
      

  2.   

    1. select SC.S#, S.SN 
    from S,C,SC 
    where C.CN='税收基础' and
          C.C#=SC.C# and
      SC.S#=S.S#;2.select S.SN, S.SD
    from S,SC 
    where SC.C#='c2' and
      SC.S#=S.S#;3.select distinct S.SN, S.SD
    from S,SC 
    where SC.C#<>'c5' and
      SC.S#=S.S#;4.select distinct S.SN, S.SD, count(SC.C#), t.num
    from S,C,SC,(select count(*) num from C) t
    where SC.S#=S.S# and
          SC.C#=C.C#
    having count(SC.C#)=t.num
    group by S.SN, S.SD;5.select distinct S.SN, S.SD, max(rownum)
    from S,SC 
    where SC.S#=S.S#
    group by S.SN, S.SD;6.select distinct S.SN, S.SD, count(SC.C#)
    from S,C,SC
    where SC.C#=C.C# and
      SC.S#=S.S#
    having count(SC.C#)>5
    group by S.SN, S.SD;