Home > Enterprise >  How do I select *unique* duplicates in MS Access SQL code from one table?
How do I select *unique* duplicates in MS Access SQL code from one table?

Time:12-20

I'm trying to use SQL to select uniquely duplicative service dates, all records of which are contained within a single table. Here's a sample starting table:

GroupID ServiceID ServiceDate
A X 1/1/2010
A Y 1/1/2010
A Z 10/1/2010

I've figured out how to find 2 different records that have the same date and get them in one row, but I end up with a somewhat duplicated table, as it's comparing each record to all others:

GroupID ServiceID1 ServiceDate1 ServiceID2 ServiceDate2
A X 1/1/2010 Y 1/1/2010
A Y 1/1/2010 X 1/1/2010

I don't want the last row, as it's essentially a duplicate of the first.

Any ideas for how to get rid of that second row?

Here's some replication code (and here's my SQL Fiddle: enter image description here

enter image description here

enter image description here

  • Related