Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
315 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 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...