选择*按Oracle SQL使用分组
我有这张桌子选择*按Oracle SQL使用分组,sql,oracle,Sql,Oracle,我有这张桌子 column1 column2 colum3 column4 colum5 column6 a b 1 2 0 x a b 1 2 0 y a b 3 0 0 z 我想把同一张唱片分组 我的sql代码看起来像这样,但它给出了相同的结果(select*from employee,其中column1='a'和colu
column1 column2 colum3 column4 colum5 column6
a b 1 2 0 x
a b 1 2 0 y
a b 3 0 0 z
我想把同一张唱片分组
我的sql代码看起来像这样,但它给出了相同的结果(select*from employee,其中column1='a'和column2='b'
)
结果应该是这样的:
column1 column2 colum3 column4 colum5
a b 1 2 0
a b 3 0 0
使用窗口函数
行编号()
尝试以下操作,下面是示例
输出:
*---------------------------------------*
| COLUMN1 COLUMN2 COLUM3 COLUMN4 COLUM5|
*---------------------------------------*
| a b 1 2 0 |
| a b 3 0 0 |
*---------------------------------------*
对于此数据集,前五列上的简单
distinct
将返回您期望的结果:
select distinct column1, column2, column3, colum4, column5
from employee
@你看过演示了吗。它给出了预期的结果,那么您是如何得到不同的结果的。@ErenDurmuş您尝试了DISTINCT吗?@forpas DISTINCT没有给出正确的结果您尝试了吗?根据您想要的结果,如何定义第2行和第3行
*---------------------------------------*
| COLUMN1 COLUMN2 COLUM3 COLUMN4 COLUM5|
*---------------------------------------*
| a b 1 2 0 |
| a b 3 0 0 |
*---------------------------------------*
select distinct column1, column2, column3, colum4, column5
from employee