Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 28th, 2005, 04:35 PM
Registered User
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL query to get duplicate entries from 2 colums

I need a SQL query to get duplicate entries from 2 different columns in the same table. In the example below in the product table, duplicate entries are in the "vpn" and "supp" column.
I only want the entries where the "vpn" is duplicated for the same "supp".

Table: Product
supp vpn
1 abc123
1 abc123
2 125abc
2 125abc
2 25895a
3 148589
4 148589
5 125abc
5 125abc
5 125adv
5 1251bc

i.e. supp 5, has four entries but I only need the first two entries b/c the vpn is duplicated for the same supp. Even though supp 3 and 4 have the same vpn, they are still uniques b/c they have different supp.

 
Old January 28th, 2005, 04:41 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

SELECT supp,vpn
FROM Product
Group By supp,vpn
Having Count(*) > 1





Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing duplicate entries avantikad XSLT 2 January 2nd, 2008 12:29 PM
How not to retrieve duplicate entries? EricTheViking Access ASP 2 January 12th, 2007 08:22 AM
Random Duplicate Entries SaraJaneQ Classic ASP Databases 6 July 16th, 2006 10:47 PM
How can I check for duplicate entries in XML gargkapil777 XSLT 2 December 22nd, 2005 01:00 PM
Eliminate duplicate entries - sql query nlicata SQL Server 2000 2 September 17th, 2003 10:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.