有一table id userid username
1 a qqq
1 b dfdd
2 c dsds
3 d sdsd
4 e dfdf
5 f ggjh
6 g ghjj
2 h kgte现要求得到id(地到的id必须是有两个或两以上相同的)即:
id userid username
1 a qqq
1 b dfdd
2 c dsds
2 h kgte
请问该怎么实现
1 a qqq
1 b dfdd
2 c dsds
3 d sdsd
4 e dfdf
5 f ggjh
6 g ghjj
2 h kgte现要求得到id(地到的id必须是有两个或两以上相同的)即:
id userid username
1 a qqq
1 b dfdd
2 c dsds
2 h kgte
请问该怎么实现
解决方案 »
- sql 语句 查询,
- sqlplus能登陆,但是使用pl/sql developer却不能
- 一个疑惑,为什么每个表都要用id这个列?
- oracle dblink很奇怪的问题
- 在ORACLE中给表见了UPDATE触发器,可一条记录字段没有任何改变情况下,仍触发了该触发器?
- 帮忙看看哪里出错了?谢谢
- oracle9i for aix下,如何配置服务?
- 用java读取oracle数据库中的char类型数据,当有汉字时,如何保证字符数和数据库中的一致
- oracle734创建数据库问题(参与有分)?
- ORA-12560: TNS: 协议适配器错误
- 这个问题这么解决?ORA-02270: no matching unique or primary key for this column-list
- 如何在ora触发器中取随机值啊
from tablename
where id in (
select id
from tablename
group by id
having count(*) > 1
)
create table t
( id number,
name number);
insert into t
select 1,536 from dual
union all
select 1,258 from dual
union all
select 2,256 from dual
union all
select 2,243 from dual
union all
select 3,189 from dual;select *
from t
where id in (select id
from
(
select id,name,
row_number() over (partition by id order by id desc) r
from t
)
where r=2)
from table_name group by id having count(id)>=2;
select *
from tablename
where id in ( select id from tablename group by id having count(id)>= 2 )
where exists(select 1 from tablename group by id having count(*)>1)
这个问题简单。。