Solved

use sql to find same record

Posted on 2004-09-16
3
814 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

831 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