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.
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.