假如我現在有A、B、C、D、E五列,其余列忽略不管A列是年份
B列是國家名
C列是數據
D列是數據
E列是數據
同一個國家有許多條數據,我想把一個國家的所有c列都相等,并且d列都相等,并且e列也都相等的的數據,這樣的n個國家的國家名顯示出來,應如何操作。謝謝。期待中

解决方案 »

  1.   

    select distinct(t1.b) from table t1,table t2 where t1.a<>t2.a and t1.b=t2.b and  and t1.c=t2.c
      

  2.   

    select b,
           count(distinct c) c_cnt,
           count(distinct d) d_cnt,
           count(distinct e) e_cnt,
      from table_name
     where c_cnt = 1
       and d_cnt = 1
       and e_cnt = 1
     group by b;
      

  3.   

    上面的写错了。不好意思,呵呵
    select b from (select b, 
          count(distinct c) c_cnt, 
          count(distinct d) d_cnt, 
          count(distinct e) e_cnt
      from a 
    group by b) where c_cnt = 1 and  d_cnt= 1 and e_cnt = 1;