Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Finding duplicates of 2 or more columns
Old 06-18-2009, 10:52 AM Finding duplicates of 2 or more columns
alf
Novice Talker

Posts: 8
Trades: 0
I've seen a lot of queries to find duplicates in a database, but after trying and failing for a long time now, i cant make my own spesific case

ExTable:
Code:
-----------------------------------------
id     name    item_id   not_important
-----------------------------------------
1      tom       4          6345
2      tom       6            42
3      tom       7           789
4      tom       4           234
5      tom       6           234
6      tom       4           365
7      tom       3            34
8      eric      3           365
9      eric      3            34
I want a result like this:
Code:
--------------------------------
 name    item_id   count(x)
--------------------------------
 eric      3          2
 tom       4          3
 tom       6          2
 tom       3          1
 tom       7          1
what would be the query?

Last edited by alf; 06-18-2009 at 11:55 AM..
alf is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-18-2009, 12:17 PM Re: Finding duplicates of 2 or more columns
alf
Novice Talker

Posts: 8
Trades: 0
Found it!
Code:
SELECT name,item_id,count(*) FROM example1 GROUP BY name, item_id HAVING count(*)>1
alf is offline
Reply With Quote
View Public Profile
 
Old 06-25-2009, 03:48 AM Re: Finding duplicates of 2 or more columns
Extreme Talker

Posts: 206
Name: vikas
Trades: 0
use the distinct on field for which you want to get unique value
__________________

Please login or register to view this content. Registration is FREE
Collection of free online books and free ebooks
Please login or register to view this content. Registration is FREE
- Free online pdf books and free pdf eBooks
vikas1234 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Finding duplicates of 2 or more columns
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10991 seconds with 12 queries