select aa.指标 
from (select distinct * from 表) aa
group by aa.指标 
having( count(*)=
        (select count(distinct 部门) from 表)
       )

解决方案 »

  1.   

    同一个部门应该没有相同的指标出现吧?也就是不存在相同的记录吧?
    所以,在指标字段中有5个相同指标的,就是所求:
    select * from 表名 where 指标 in (select 指标 from 表名 group by 指标 having count(指标)=5)其中:select 指标 from 表名 group by 指标 having count(指标)=5是你要求出的指标
      

  2.   

    lsxaa(小李铅笔刀)写得更详细,
    他的办法可以了
      

  3.   

    select * from 表名 a where (select count(*) from  表名 b where b.指标 = a.指标) = (select count(*) from (select distinct 部门 from 表名) )
      

  4.   

    不行,没有做到啊```  我也想到了这一层SELECT Target_Name
    FROM Department_Target
    WHERE Department_Id IN (1,2)
    GROUP BY Target_Name可是后面加了
    HAVING Count(*) = 2
    还是求不出来啊
      

  5.   

    哎,是我的错```因为我的表里还有时间的字段
    所以导致了同一个部门同一个指标的记录有2条以上,所以导致了HAVING Count(*) = 2求不到结果,因为有2条后就应该 = 3 了,加上时间条件就好了```失败```是说怎么搞不定