List all records that appear more than once

G

G.

I have a query named readmit_2 that lists medical encounters. I need to build
another query that lists only those encounters that are a readmission. The
distinguishing characteristic is the Medical Record # (mr_num). If the mr_num
appears more than once, it is a readmission. However, I need all the records
that appear more than once listed so they can be seen - I just don't want to
see any records that only have one encounter (one mr_num). I am not
completely positive that my query is working correctly. My current SQL code
is:

SELECT *
FROM Readmit_2
WHERE (((Readmit_2.mr_num) In (SELECT MR_num
FROM [Readmit_2]
GROUP BY MR_Num
HAVING Count(MR_Num) > 1)));

Can someone please help with confirming if the code looks correct or if I am
missing something? Thank you.
 
D

Dale Fye

That looks correct to me.

Did you know that the query wizard has a "Find Duplicates" query that walks
you through the process of doing this? You could run that wizard and then
compare the SQL strings.

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top