Solved

use sql to find same record

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

751 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