473,757 Members | 10,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL Query - Selecting records that repeat / occur more than once in a table -- newbe question

I need to find customer's names that repeat / occur more than once in
the same table. I have treid many options and I have tried comparing
the column to itself but Oracle gives me an error.

SELECT a.customer_name , b.customer_name
FROM dtb_customer a, dtb_customer b
where a.dtb_customer = b.dtb_customer
and b.customer > 1
Any help would be appreciated.

Thanks in advance.
Jul 19 '05 #1
6 58195
On 11 Feb 2004, nb****@yahoo.co m wrote:
I need to find customer's names that repeat / occur more than
once in the same table. I have treid many options and I have
tried comparing the column to itself but Oracle gives me an
error.


select cust_nm, count(*)
from table
group cust_nm
having count(*) > 1;

--
Galen Boyer
Jul 19 '05 #2
nb****@yahoo.co m (Nimesh) wrote in message news:<ec******* *************** ****@posting.go ogle.com>...
I need to find customer's names that repeat / occur more than once in
the same table. I have treid many options and I have tried comparing
the column to itself but Oracle gives me an error.

SELECT a.customer_name , b.customer_name
FROM dtb_customer a, dtb_customer b
where a.dtb_customer = b.dtb_customer
and b.customer > 1
Any help would be appreciated.

Thanks in advance.


Can you explain your SQL? How is it counting names??? You need an
aggregate query to accomplish this...

SELECT customer_name, count(*) cnt
from dtb_customer
group by customer_name

this will give you the count per customer_name

to accomplish your goal...either wrap the sql like this...

select *
from
(
SELECT customer_name, count(*) cnt
from dtb_customer
group by customer_name
)
where cnt > 1

or get the same exact effect with the HAVING CLAUSE...

SELECT customer_name, count(*) cnt
from dtb_customer
group by customer_name
having count(*) > 1

Dave
Jul 19 '05 #3
nb****@yahoo.co m (Nimesh) wrote in message news:<ec******* *************** ****@posting.go ogle.com>...
I need to find customer's names that repeat / occur more than once in
the same table. I have treid many options and I have tried comparing
the column to itself but Oracle gives me an error.

SELECT a.customer_name , b.customer_name
FROM dtb_customer a, dtb_customer b
where a.dtb_customer = b.dtb_customer
and b.customer > 1
Any help would be appreciated.

Thanks in advance.


select a.customer_name , count(*)
from dtb_customer a
group by a.customer_name
having count(*) > 1

That's all!

Sybrand Bakker
Senior Oracle DBA
Jul 19 '05 #4
nb****@yahoo.co m (Nimesh) wrote in message news:<ec******* *************** ****@posting.go ogle.com>...
I need to find customer's names that repeat / occur more than once in
the same table. I have treid many options and I have tried comparing
the column to itself but Oracle gives me an error.

SELECT a.customer_name , b.customer_name
FROM dtb_customer a, dtb_customer b
where a.dtb_customer = b.dtb_customer
and b.customer > 1
Any help would be appreciated.

Thanks in advance.


Standard way of discovering duplicates would be like this :
select a.customer_name , count(*)
from dtb_customer a
group by a.customer_name
having count(*) > 1

/KiBeHa
Jul 19 '05 #5
nb****@yahoo.co m (Nimesh) wrote in message news:<ec******* *************** ****@posting.go ogle.com>...
I need to find customer's names that repeat / occur more than once in
the same table. I have treid many options and I have tried comparing
the column to itself but Oracle gives me an error.

SELECT a.customer_name , b.customer_name
FROM dtb_customer a, dtb_customer b
where a.dtb_customer = b.dtb_customer
and b.customer > 1
Any help would be appreciated.

Thanks in advance.


Use COUNT(*), GROUP BY and HAVING.
Jul 19 '05 #6
SELECT customer_name, Count(*) num_occurances
FROM dtb_customer
group by customer_name
having count(*) > 1

will do it..
nb****@yahoo.co m (Nimesh) wrote in message news:<ec******* *************** ****@posting.go ogle.com>...
I need to find customer's names that repeat / occur more than once in
the same table. I have treid many options and I have tried comparing
the column to itself but Oracle gives me an error.

SELECT a.customer_name , b.customer_name
FROM dtb_customer a, dtb_customer b
where a.dtb_customer = b.dtb_customer
and b.customer > 1
Any help would be appreciated.

Thanks in advance.

Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
348
by: JB | last post by:
I have a table for recordings, a table for playlists, and a table for playlist details, that uses the primary key from the recordings and playists tables as its primary key. I would like to develop playlists quickly, by just typing in the information, and not selecting recordings from the recordings list. To accomplish that I set up a default recording, recording ID#1, and tried to put this on the playlist, the problem is that access...
4
5103
by: Kathy | last post by:
I have a query that is being created in code. When the query is executed I get the error: "The specified field 'Acct' could refer to more than one table listed in the FROM clause". As you can see below, the 'Acct' field is fully qualified in the subselect. What is interesting is if I cut and re-paste the same exact query in the SQL view of design mode for the query object, it works fine. It even works fine if all I do is remove the...
1
2023
by: Jim | last post by:
I have created a windows form that contains several tab pages which contain a panels. On a tab page I am trying to dynamically create a series of buttons in that pages panel. I am failing because I can not find the proper way to point to the specific tab page and its panel when creating the buttons. I also need to dynamically change the background color property of each button as it is clicked.
17
2720
by: Eric_Dexter | last post by:
def simplecsdtoorc(filename): file = open(filename,"r") alllines = file.read_until("</CsInstruments>") pattern1 = re.compile("</") orcfilename = filename + "orc" for line in alllines: if not pattern1 print >>orcfilename, line I am pretty sure my code isn't close to what I want. I need to be able
1
1911
by: wbsurfver | last post by:
Here is the problem, I am working with a bunch of old code so I can really restructure the includes, otherwise I guess I could change all the #include statements to #include-once. Anyway, If I have a file with a class like this: Class myClass end class I get a "name redefined" error. I've been seeing these and indeed from
1
2032
by: mfaisalwarraich | last post by:
Hi, i want to show my query the records which was entered yesterday. for example today is December 25, 2007 but when i run this query this query should reflect the records with the date December 24, 2007. What is the syntax doing this? please tell me. thank u.
22
6914
by: Simon Forman | last post by:
Is there a more efficient way to do this? def f(L): '''Return a set of the items that occur more than once in L.''' L = list(L) for item in set(L): L.remove(item) return set(L)
6
253
by: Nimesh | last post by:
I need to find customer's names that repeat / occur more than once in the same table. I have treid many options and I have tried comparing the column to itself but Oracle gives me an error. SELECT a.customer_name, b.customer_name FROM dtb_customer a, dtb_customer b where a.dtb_customer = b.dtb_customer and b.customer 1
0
10072
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9906
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6562
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5172
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3829
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2698
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.