我正在使用此查询在表中查找重复值:
select col1,
count(col1)
from table1
group by col1
having count (col1) > 1
order by 2 desc;
Run Code Online (Sandbox Code Playgroud)
但是我想在同一个表中添加另一个列,如下所示:
select col1,
col2,
count(col1)
from table1
group by col1
having count (col1) > 1
order by 2 desc;
Run Code Online (Sandbox Code Playgroud)
我的ORA-00979第二个查询出错了
如何在搜索中添加其他列?
你的查询应该是
SELECT * FROM (
select col1,
col2,
count(col1) over (partition by col1) col1_cnt
from table1
)
WHERE col1_cnt > 1
order by 2 desc;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16614 次 |
| 最近记录: |