select aa.指标
from (select distinct * from 表) aa
group by aa.指标
having( count(*)=
(select count(distinct 部门) from 表)
)
from (select distinct * from 表) aa
group by aa.指标
having( count(*)=
(select count(distinct 部门) from 表)
)
调试欢乐多
所以,在指标字段中有5个相同指标的,就是所求:
select * from 表名 where 指标 in (select 指标 from 表名 group by 指标 having count(指标)=5)其中:select 指标 from 表名 group by 指标 having count(指标)=5是你要求出的指标
他的办法可以了
FROM Department_Target
WHERE Department_Id IN (1,2)
GROUP BY Target_Name可是后面加了
HAVING Count(*) = 2
还是求不出来啊
所以导致了同一个部门同一个指标的记录有2条以上,所以导致了HAVING Count(*) = 2求不到结果,因为有2条后就应该 = 3 了,加上时间条件就好了```失败```是说怎么搞不定