Access - create table with duplicates across columns

I have a table with the following columns:

A - Name
B - Procedure
C - Outcome
D - Cost

The name in column A can appear on multiple rows.

I would like to create a new table B, that will export only records where columns B - D have repeat values. Example

Row 1: JOHN DOE - Foot Massage - Relaxed - $40
Row 2: JOHN DOE - Foot Massage - Tense - $40
Row 3:JOHN DOE - Foot Massage - Relaxed - $40
Row 4:JOHN OE - Foot Massage - Relaxed - $45

In this example, only rows 1 and 3 would be exported to the new table.

Thank you.
exp vgAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PatHartmanCommented:
Are you sure you need a new table?

Use the wizard to create a find duplicates query.  Then if you must physically capture the data, create a make table query that uses the find duplicates query you just created instead of the base table.
YZlatCommented:
SELECT Table1.A,Table1.B,Table1.C,Table1.D
FROM Table1
GROUP BY Table1.[A], Table1.[B], Table1.[C], Table1.[D]
HAVING (((Count(Table1.[A]))>1) AND ((Count(Table1.[D]))>1));

Open in new window

the above will give you:

JOHN DOE - Foot Massage - Relaxed - $40
Rey Obrero (Capricorn1)Commented:
In access, you can create a Find duplicate query using the query wizard

from the ribbon
create > query wizard, select Find duplicates query
select the table then select the fields B-D
select field A
run the query

this is the SQL view of the query

SELECT tableZ.[Procedure], tableZ.[Outcome], tableZ.[Cost], tableZ.[Name]
FROM tableZ
WHERE (((tableZ.[Procedure]) In (SELECT [Procedure] FROM [tableZ] As Tmp GROUP BY [Procedure],[Outcome],[Cost] HAVING Count(*)>1  And [Outcome] = [tableZ].[Outcome] And [Cost] = [tableZ].[Cost])))
ORDER BY tableZ.[Procedure], tableZ.[Outcome], tableZ.[Cost];


save the query as qryDuplicates.

then create a make table query to create your new table

SELECT qryDuplicates.* INTO [Table B]
FROM qryDuplicates;
PatHartmanCommented:
@YZlat,
Count(Table1.[A]) and Count(Table1.[D])  both count all the non-null records in the domain.  The only time they will be different is if A or D has any null values.  Count(*) is always more efficient since the query engine can frequently use statistics to derive the count whereas Count(something) forces the query engine to do a row by row analysis of every record.  So the only time you should use Count(something) is if you specifically want to include records with null values in your resultset but you want a count of the non-null values.   Your solution also aggregates the data and the OP asked for both records to be selected, not just an aggregate.

@exp vg,
The query you need will look more like:
SELECT Table3.[ClientName], Table3.[Procedure], Table3.[Outcome], Table3.[Cost], Table3.[PrimaryKey]
FROM Table3
WHERE (((Table3.[ClientName]) In (SELECT [ClientName] FROM [Table3] As Tmp GROUP BY [ClientName],[Procedure],[Outcome],[Cost] HAVING Count(*)>1  And [Procedure] = [Table3].[Procedure] And [Outcome] = [Table3].[Outcome] And [Cost] = [Table3].[Cost])))
ORDER BY Table3.[ClientName], Table3.[Procedure], Table3.[Outcome], Table3.[Cost];
But use the wizard to build it.  Select only the columns you care to group by but then select the remaining columns for output so you get entire records.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
exp vgAuthor Commented:
Thank you everyone.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.