Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
230 views
in Technique[技术] by (71.8m points)

sql - 如何在Oracle的表中找到重复的值?(How do I find duplicate values in a table in Oracle?)

What's the simplest SQL statement that will return the duplicate values for a given column and the count of their occurrences in an Oracle database table?

(什么是最简单的SQL语句,该语句将返回给定列的重复值及其在Oracle数据库表中的出现次数?)

For example: I have a JOBS table with the column JOB_NUMBER .

(例如:我有一个JOBS表,其JOB_NUMBER 。)

How can I find out if I have any duplicate JOB_NUMBER s, and how many times they're duplicated?

(如何确定我是否有重复的JOB_NUMBER ,以及它们重复了多少次?)

  ask by Andrew translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
SELECT column_name, COUNT(column_name)
FROM table_name
GROUP BY column_name
HAVING COUNT(column_name) > 1;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...