答案 0 :(得分:1)
您可以使用group by
和having
:
select psa_psofk
from mytable
group by psa_psofk
having count(*) > 1
这假定没有重复的(psa_psofk, psa_prdfk)
。否则,您需要将having
子句更改为:
having count(distinct psa_prdfk) > 1
如果要整行,则一个选项使用exists
:
select t.*
from mytable t
where exists (
select 1
from mytable t1
where t1.psa_psofk = t.psa_psofk and t1.psa_prdfk <> t.psa_prdfk
)