Solved

use sql to find same record

Posted on 2004-09-16
3
826 Views
Last Modified: 2010-05-18
Hi,

I have a table contain 1000 record, I would like to search whether got any record got the same data, for example I would like to check 'tel_no' field, see whether the record contain 2 or more same data inside, anybody knows how to write an sql statement to get it out?

for example

Name        tel_no       address      sex
a               5555        abc             m
b               5656        bbb             f
c               5555         dfdf             m
.
.

how to write a sql statement to see find out the field 'tel_no' actually contain same data '5555' twice here?
0
Comment
Question by:kevin_yee_teck_ping
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 15

Accepted Solution

by:
andrewst earned 100 total points
ID: 12072967
select tel_no, count(*)
from table
group by tel_no
having count(*) > 1;
0
 
LVL 13

Expert Comment

by:riazpk
ID: 12073586
select * from
(
select name,tel_no,address,sex, row_number() over (partition by tel_no) rno
from table
)
where rno<>1
0
 
LVL 3

Expert Comment

by:oratim
ID: 12074292
select * from table where tel_no in (select tel_no from table having count(tel_no) > 1 group by tel_no)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question