have a try:select CLIENT_NBR  from  ticket t
 where not exists( select * from performance p where t.perf_id=p.perf_id
 and not exists ( select *  from production d where d.prod_id=p.prod_id))

解决方案 »

  1.   

    SQL> select CLIENT_NBR  from  ticket t
      2   where not exists( select * from performance p where t.perf_id=p.perf_id
      3   and not exists ( select *  from production d where d.prod_id=p.prod_id));CLIENT_NBR
    ----------
             1
             2
             3
             4
             6
             7
             5
             1
             4
             1
             1CLIENT_NBR
    ----------
             1
             113 rows selected.这是welyngj(平平淡淡)的方法输出的结果
    能解释一下这句命令的作用吗?我理解不了
      

  2.   

    production和ticket两者的关系是什么/
      

  3.   

    select b.client_nbr 
    form 
      (SELECT count(distinct PROD_ID) as cnt
      FROM production) a,
      (select count(distinct PERF_ID) as cnt ,client_nbr
      from ticket
      group by client_nbr) b
      where a.cnt=b.cnt试试如何
      

  4.   

    create or replace procedure pro 
    is
    cursor cura is select distinct  client_nbr from ticket;
    cursor curb(c ticket.client_nbr%type) is select perf_id from ticket where client_nbr=c;
    cursor curc(a  performance.perf_id%type) is select distinct  prod_id from production where perf_id=a;
    have number;
    begin
    for curarec in cura loop
        for curbrec(curarec.client_nbr) in curb loop
            for curcrec(curbrec.perf_id) in curc loop
            have:=have+1;
            end loop;
        end loop;
    if have=6 then
    dbms_output.put_line(curarec.client_nbr);
    end loop;
    end pro;
    不知道行不行,你试试!
            
      

  5.   

    sorry
    少了一行,应该是:
    if have=6 then
    dbms_output.put_line(curarec.client_nbr);
    end if;
      

  6.   

    回lvjack(叶飞) :
    问题是perf_id并不等于prod_id,这个关系在performance表中表示出来了。
    clinet_nbr为1的那个客户预订了perfomrnace1,2,3,4,5,6,然后在performance表中可以看出perf_id 1,2,3,4,5,6是和prod_id 1,2,3,4,5,6联系的,所以说client_nbr 1预定了所有的production。其他client(client_nbr为2,3,4,5,6,7的client)都没有预定所有的production。
    回maohuijian(mao) ( ) :那段命令是在SQL*Plus Worksheet中运行的吗(人本还是初学者)?
    我在里面输入命令说,返回错误:
    Warning: Procedure created with compilation errors.
      

  7.   

    下面改的你看了吗?少了一句
    end if;
    别忘了啊
      

  8.   

    我也加了这一句 不过还是一样的提示错误
    你写的是PL/SQL语句吗?是的话,我先去研究研究PL/SQL
      

  9.   

    是啊,那是个过程啊
    提示的错误是说的过程有编译错误!
    我知道那里错了 have 我没赋初值!
    create or replace procedure pro 
    is
    cursor cura is select distinct  client_nbr from ticket;
    cursor curb(c ticket.client_nbr%type) is select perf_id from ticket where client_nbr=c;
    cursor curc(a  performance.perf_id%type) is select distinct  prod_id from production where perf_id=a;
    have number default 0;
    begin
    for curarec in cura loop
        for curbrec(curarec.client_nbr) in curb loop
            for curcrec(curbrec.perf_id) in curc loop
            have:=have+1;
            end loop;
        end loop;
    if have=6 then
    dbms_output.put_line(curarec.client_nbr);
    end if;
    end loop;
    end pro;这次你试试!
      

  10.   

    select t.client_nbr
    from ticket t, performance pe, production pr
    where pe.prod_id=pr.prod_id
      and t.perf_id=pe.perf_id
    group by t.client_nbr
    having count(distinct pr.prod_id)=(
      select count(*) from production
    )
      

  11.   

    郁闷啊!!!!!!!!!!!!!!!!!!!!!!!!!!!
    create or replace procedure pro 
    is
    cursor cura is select distinct  client_nbr from ticket;
    cursor curb(c ticket.client_nbr%type) is select sum(1) aa from production a where 
             a.prod_id in ( select prod_id from ferformance where perf_id in (select 
             perf_id from ticket where client_nbr=c));
    begin
    for curarec in cura loop
        for curbrec(curarec.client_nbr) in curb loop
           if curbrec.aa=6 then
                dbms_output.put_line(curarec.client_nbr);
           end if;
        end loop;
    end loop;
    end pro;
       
    这次试试!不行的话,我下午再来!
    郁闷啊!我的qq95198443 加我!我给你发qq上。
    丢人了,嘿嘿!
      

  12.   

    把mao的东西粘贴在SQL上后,再用execute pro;
      

  13.   

    To  MountLion(闷头睡):你好厉害,运行的结果就是我想要的
    学习中......
      

  14.   

    To  maohuijian(mao)
    我给你在qq上留言了