2015-10-15 69 views
0

我无法用SQL语句处理,我不得不要求您提供帮助。 表包含3列:oracle查询选择分组数据

COlumn1 Column2 Column3 
12345  1  Sometext1 
23456  1  Sometext2 
34567  1  Sometext3 
45678  2  Sometext4 
56789  2  Sometext5 

我试图写一个选择像数据的查询:

12345 1 Sometext1 
12345 1 Sometext2 
12345 1 Sometext3 
23456 1 Sometext1 
23456 1 Sometext2 
23456 1 Sometext3 
34567 1 Sometext1 
34567 1 Sometext2 
34567 1 Sometext3 
45678 2 Sometext4 
45678 2 Sometext5 
56789 2 Sometext4 
56789 2 Sometext5 

一般1行的样子:

COlumn1 Column2 Column3 
**12345**  **1**  **Sometext1** 
23456  1  **Sometext2** 
34567  1  **Sometext3** 
45678  2  Sometext4 
56789  2  Sometext5 

等。 ..

+0

所以你想要Column2的每个值的Column1和Column2的所有组合? (有效地平均每个Column2值的行数,3 - > 9,2 - > 4) – knittl

回答

2

如果我理解你对,这是你需要的:

SELECT t1.Column1, t1.Column2, t2.Column3 
FROM your_table t1 join your_table t2 on t1.Column2=t2.Column2