我只想获取重复的行,其中name列中的值重复多次,而没有count列,我不想对它们进行分组。举例如下。例如
例如,这是table:-
id | name | project
----+--------+---------
1 | aditya | java
2 | aditya | cloud
3 | bradly | go
4 | cooper | java
5 | alexa | elixir
6 | jason | search
7 | jason | java
结果应为:-
id | name | project
----+--------+---------
1 | aditya | java
2 | aditya | cloud
6 | jason | search
7 | jason | java
2条答案
按热度按时间uxhixvfz1#
一个简单的方法是
exists
:也可以使用窗口功能:
xdnvmnnf2#
你也可以使用
join
或者一个in
```select a.*
from t a
inner join t b on a.name=b.name and a.id<>b.id
select *
from t
where name in (select name from t group by name having count(*)>1);