# Thread: Relational Algebra - Find Duplicates

1. Registered User
Join Date
Oct 2013
Posts
3

## Unanswered: Relational Algebra - Find Duplicates

What operation would be used to find duplicate entries in just one field for one table in a database? So like how would you find all of the entries with a surname that is repeated?

2. Registered User
Join Date
Nov 2003
Posts
2,988
Code:
```select surname
from some_table
group by surname
having count(*) > 1```
You should really read a good SQL tutorial - this is basic SQL knowledge.

3. Registered User
Join Date
Oct 2013
Posts
3
Originally Posted by shammat
Code:
```select surname
from some_table
group by surname
having count(*) > 1```
You should really read a good SQL tutorial - this is basic SQL knowledge.
Thank you for the help, but I am not looking for the SQL syntax. I have general knowledge of SQL but this is for a university coursework to do with relational algebra. I have to use relational algebra only so things like project, natjoin, equijoin etc.

Here is the question in full (I don't want the answer to the question, I just want some help on what operation to use because I haven't picked this up in a lecture and have went through the slides several times):

3. Find the age and address of the patients that have had at least two operations with broken leg.

The part I'm stumped on is finding patients that have two entries of operation type "broken leg" in the Completed_Operations table.

4. Registered User
Join Date
Dec 2013
Posts
46
Pokie,

First make a query to join the Patients table to the Completed_Operations table.
You'll group by Patient, OperationType.
Use the Having clause to limit results to "broken leg" and at least two entries.

Then join your Patients table to the query to pick up the patient's age/address.

You'll have to supply the "relational algebra" words, but that's what you have to do.

hth,
Wayne

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•