没有使用 Oracle Analytical 函数的任何其他选项

Any other option is there without using Oracle Analytical function

有人可以帮我解决这个问题吗?

CREATE TABLE TT (
     A NUMBER PRIMARY KEY,
     B VARCHAR2(5)
);

insert into tt values (11,'A'); 
insert into tt values (12,'A'); 
insert into tt values (13,'B'); 
insert into tt values (14,'B'); 
insert into tt values (15,'C'); 
insert into tt values (16,'D'); 
insert into tt values (17,'E'); 
insert into tt values (18,'E'); 
insert into tt values (19,'F'); 
insert into tt values (20,'F'); 

COMMIT;

SELECT * FROM TT; 

+---+---+
| A | B |
+---+---+
|11 | A |
|12 | A |
|13 | B |
|14 | B |
|15 | C |
|16 | D |
|17 | E |
|18 | E |
|19 | F |
|20 | F |
+---+---+

我的要求是 'B' 列映射了多个 'A' 列 Like(值“E”映射了“A”列中的两行) o/p

+---+
| A |
+---+
| 11| 
| 12| 
| 13| 
| 14| 
| 17| 
| 18| 
| 19| 
| 20| 
+---+

我使用以下分析查询实现了。我想知道是否可以在没有解析功能的情况下使用存档。

select a
from (SELECT tt.*, COUNT(*) over (partition by b) cnt
      FROM TT
     )
where cnt >= 2;

您可以通过以下方式使用群组查找候选人:

select a 
from tt
where B in (
            select B
            from tt
            group by b
            having count(*) >= 2);

聚合很简单:

select a
from tt 
where b in (select b from tt group by b having count(*) > 1);

请注意,您可以避免使用聚合,因为 Oracle 提供了 rowid 伪列:

select a
from tt
where exists (select 1
              from tt tt2
              where tt2.b = tt.b and tt2.rowid <> tt.rowid
             );
select a from temp a where  exists ( select null from temp b where a.b = b.b group by b having count(1) >= 2)

这是替代方法solution.i认为在这种情况下您无法避免使用聚合函数。