SlideShare a Scribd company logo
1 of 1
Download to read offline
Write an SQL statement to answer the question.
Primary keys are( BOLD and italicized) and attributes with the same names in different tables
are foreign keys.
Doctors(doctorId, doctorName, specialty)
Patients(patientId, patientName, sex, patientBalance, numberOfVisits)
Records(doctorId, patientId, date, diagnosis, visitCost)
1. For each doctor, list doctor identifier, doctor name and the total number of visits that were
administered by the doctor.
Solution
Answer:
select d.doctorId, d.doctorName, sum(p.numberOfVisits) from Doctors d, Patients p, Records r
where d.doctorId = r.doctorId and r.patientId = p.patientId group by d.doctorId, d.doctorName;

More Related Content

More from archigallery1298

Are the structures present in the organisms or not Amswer Yes or No.pdf
Are the structures present in the organisms or not Amswer Yes or No.pdfAre the structures present in the organisms or not Amswer Yes or No.pdf
Are the structures present in the organisms or not Amswer Yes or No.pdfarchigallery1298
 
3. When and what was the first operating system which integrated sec.pdf
3. When and what was the first operating system which integrated sec.pdf3. When and what was the first operating system which integrated sec.pdf
3. When and what was the first operating system which integrated sec.pdfarchigallery1298
 
You are running the Windows installation setup for Windows Vista on .pdf
You are running the Windows installation setup for Windows Vista on .pdfYou are running the Windows installation setup for Windows Vista on .pdf
You are running the Windows installation setup for Windows Vista on .pdfarchigallery1298
 
1.Based on current fossil evidenceSelect onea. whales were lik.pdf
1.Based on current fossil evidenceSelect onea. whales were lik.pdf1.Based on current fossil evidenceSelect onea. whales were lik.pdf
1.Based on current fossil evidenceSelect onea. whales were lik.pdfarchigallery1298
 
Which of the following is NOT a characteristic of the normal probabi.pdf
Which of the following is NOT a characteristic of the normal probabi.pdfWhich of the following is NOT a characteristic of the normal probabi.pdf
Which of the following is NOT a characteristic of the normal probabi.pdfarchigallery1298
 
Which addresses do Physical layer devices—such as repeaters and hubs.pdf
Which addresses do Physical layer devices—such as repeaters and hubs.pdfWhich addresses do Physical layer devices—such as repeaters and hubs.pdf
Which addresses do Physical layer devices—such as repeaters and hubs.pdfarchigallery1298
 
What structure of the femur fits in the acetabular fossa Which Is s.pdf
What structure of the femur fits in the acetabular fossa  Which Is s.pdfWhat structure of the femur fits in the acetabular fossa  Which Is s.pdf
What structure of the femur fits in the acetabular fossa Which Is s.pdfarchigallery1298
 
What is HIPAA Why was it passed What arc the potential benefits to .pdf
What is HIPAA Why was it passed What arc the potential benefits to .pdfWhat is HIPAA Why was it passed What arc the potential benefits to .pdf
What is HIPAA Why was it passed What arc the potential benefits to .pdfarchigallery1298
 
what are the similarties and difference between bacterial growth .pdf
what are the similarties and difference between bacterial growth .pdfwhat are the similarties and difference between bacterial growth .pdf
what are the similarties and difference between bacterial growth .pdfarchigallery1298
 
What are some examples of analog data What about digital dataS.pdf
What are some examples of analog data What about digital dataS.pdfWhat are some examples of analog data What about digital dataS.pdf
What are some examples of analog data What about digital dataS.pdfarchigallery1298
 
This problem is about Lebesgue Integration problem. Thank you fo.pdf
This problem is about Lebesgue Integration problem. Thank you fo.pdfThis problem is about Lebesgue Integration problem. Thank you fo.pdf
This problem is about Lebesgue Integration problem. Thank you fo.pdfarchigallery1298
 
Three types of natural selection Classify each description according.pdf
Three types of natural selection  Classify each description according.pdfThree types of natural selection  Classify each description according.pdf
Three types of natural selection Classify each description according.pdfarchigallery1298
 
1. what are some of the positives and negatives of being a proje.pdf
1. what are some of the positives and negatives of being a proje.pdf1. what are some of the positives and negatives of being a proje.pdf
1. what are some of the positives and negatives of being a proje.pdfarchigallery1298
 
1. Identify a key characteristic of architectural approaches and com.pdf
1. Identify a key characteristic of architectural approaches and com.pdf1. Identify a key characteristic of architectural approaches and com.pdf
1. Identify a key characteristic of architectural approaches and com.pdfarchigallery1298
 
The file c_wiki.txt contains the first section of the Wikipedia page.pdf
The file c_wiki.txt contains the first section of the Wikipedia page.pdfThe file c_wiki.txt contains the first section of the Wikipedia page.pdf
The file c_wiki.txt contains the first section of the Wikipedia page.pdfarchigallery1298
 
Taxation and Representation - A DebateIn the years between the end.pdf
Taxation and Representation - A DebateIn the years between the end.pdfTaxation and Representation - A DebateIn the years between the end.pdf
Taxation and Representation - A DebateIn the years between the end.pdfarchigallery1298
 
Simularities and differances between social inquiries and everyday a.pdf
Simularities and differances between social inquiries and everyday a.pdfSimularities and differances between social inquiries and everyday a.pdf
Simularities and differances between social inquiries and everyday a.pdfarchigallery1298
 
Round seeds (R) is dominant to wrinkled seeds (r), and yellow seeds (.pdf
Round seeds (R) is dominant to wrinkled seeds (r), and yellow seeds (.pdfRound seeds (R) is dominant to wrinkled seeds (r), and yellow seeds (.pdf
Round seeds (R) is dominant to wrinkled seeds (r), and yellow seeds (.pdfarchigallery1298
 
QUESTION 13Expensing an on item only on the tax return that should.pdf
QUESTION 13Expensing an on item only on the tax return that should.pdfQUESTION 13Expensing an on item only on the tax return that should.pdf
QUESTION 13Expensing an on item only on the tax return that should.pdfarchigallery1298
 
On December 2, 2014, Ewell Company purchases a piece of land from th.pdf
On December 2, 2014, Ewell Company purchases a piece of land from th.pdfOn December 2, 2014, Ewell Company purchases a piece of land from th.pdf
On December 2, 2014, Ewell Company purchases a piece of land from th.pdfarchigallery1298
 

More from archigallery1298 (20)

Are the structures present in the organisms or not Amswer Yes or No.pdf
Are the structures present in the organisms or not Amswer Yes or No.pdfAre the structures present in the organisms or not Amswer Yes or No.pdf
Are the structures present in the organisms or not Amswer Yes or No.pdf
 
3. When and what was the first operating system which integrated sec.pdf
3. When and what was the first operating system which integrated sec.pdf3. When and what was the first operating system which integrated sec.pdf
3. When and what was the first operating system which integrated sec.pdf
 
You are running the Windows installation setup for Windows Vista on .pdf
You are running the Windows installation setup for Windows Vista on .pdfYou are running the Windows installation setup for Windows Vista on .pdf
You are running the Windows installation setup for Windows Vista on .pdf
 
1.Based on current fossil evidenceSelect onea. whales were lik.pdf
1.Based on current fossil evidenceSelect onea. whales were lik.pdf1.Based on current fossil evidenceSelect onea. whales were lik.pdf
1.Based on current fossil evidenceSelect onea. whales were lik.pdf
 
Which of the following is NOT a characteristic of the normal probabi.pdf
Which of the following is NOT a characteristic of the normal probabi.pdfWhich of the following is NOT a characteristic of the normal probabi.pdf
Which of the following is NOT a characteristic of the normal probabi.pdf
 
Which addresses do Physical layer devices—such as repeaters and hubs.pdf
Which addresses do Physical layer devices—such as repeaters and hubs.pdfWhich addresses do Physical layer devices—such as repeaters and hubs.pdf
Which addresses do Physical layer devices—such as repeaters and hubs.pdf
 
What structure of the femur fits in the acetabular fossa Which Is s.pdf
What structure of the femur fits in the acetabular fossa  Which Is s.pdfWhat structure of the femur fits in the acetabular fossa  Which Is s.pdf
What structure of the femur fits in the acetabular fossa Which Is s.pdf
 
What is HIPAA Why was it passed What arc the potential benefits to .pdf
What is HIPAA Why was it passed What arc the potential benefits to .pdfWhat is HIPAA Why was it passed What arc the potential benefits to .pdf
What is HIPAA Why was it passed What arc the potential benefits to .pdf
 
what are the similarties and difference between bacterial growth .pdf
what are the similarties and difference between bacterial growth .pdfwhat are the similarties and difference between bacterial growth .pdf
what are the similarties and difference between bacterial growth .pdf
 
What are some examples of analog data What about digital dataS.pdf
What are some examples of analog data What about digital dataS.pdfWhat are some examples of analog data What about digital dataS.pdf
What are some examples of analog data What about digital dataS.pdf
 
This problem is about Lebesgue Integration problem. Thank you fo.pdf
This problem is about Lebesgue Integration problem. Thank you fo.pdfThis problem is about Lebesgue Integration problem. Thank you fo.pdf
This problem is about Lebesgue Integration problem. Thank you fo.pdf
 
Three types of natural selection Classify each description according.pdf
Three types of natural selection  Classify each description according.pdfThree types of natural selection  Classify each description according.pdf
Three types of natural selection Classify each description according.pdf
 
1. what are some of the positives and negatives of being a proje.pdf
1. what are some of the positives and negatives of being a proje.pdf1. what are some of the positives and negatives of being a proje.pdf
1. what are some of the positives and negatives of being a proje.pdf
 
1. Identify a key characteristic of architectural approaches and com.pdf
1. Identify a key characteristic of architectural approaches and com.pdf1. Identify a key characteristic of architectural approaches and com.pdf
1. Identify a key characteristic of architectural approaches and com.pdf
 
The file c_wiki.txt contains the first section of the Wikipedia page.pdf
The file c_wiki.txt contains the first section of the Wikipedia page.pdfThe file c_wiki.txt contains the first section of the Wikipedia page.pdf
The file c_wiki.txt contains the first section of the Wikipedia page.pdf
 
Taxation and Representation - A DebateIn the years between the end.pdf
Taxation and Representation - A DebateIn the years between the end.pdfTaxation and Representation - A DebateIn the years between the end.pdf
Taxation and Representation - A DebateIn the years between the end.pdf
 
Simularities and differances between social inquiries and everyday a.pdf
Simularities and differances between social inquiries and everyday a.pdfSimularities and differances between social inquiries and everyday a.pdf
Simularities and differances between social inquiries and everyday a.pdf
 
Round seeds (R) is dominant to wrinkled seeds (r), and yellow seeds (.pdf
Round seeds (R) is dominant to wrinkled seeds (r), and yellow seeds (.pdfRound seeds (R) is dominant to wrinkled seeds (r), and yellow seeds (.pdf
Round seeds (R) is dominant to wrinkled seeds (r), and yellow seeds (.pdf
 
QUESTION 13Expensing an on item only on the tax return that should.pdf
QUESTION 13Expensing an on item only on the tax return that should.pdfQUESTION 13Expensing an on item only on the tax return that should.pdf
QUESTION 13Expensing an on item only on the tax return that should.pdf
 
On December 2, 2014, Ewell Company purchases a piece of land from th.pdf
On December 2, 2014, Ewell Company purchases a piece of land from th.pdfOn December 2, 2014, Ewell Company purchases a piece of land from th.pdf
On December 2, 2014, Ewell Company purchases a piece of land from th.pdf
 

Recently uploaded

NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111GangaMaiya1
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonhttgc7rh9c
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxCeline George
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of PlayPooky Knightsmith
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfstareducators107
 

Recently uploaded (20)

NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of Play
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 

Write an SQL statement to answer the question.Primary keys are( BO.pdf

  • 1. Write an SQL statement to answer the question. Primary keys are( BOLD and italicized) and attributes with the same names in different tables are foreign keys. Doctors(doctorId, doctorName, specialty) Patients(patientId, patientName, sex, patientBalance, numberOfVisits) Records(doctorId, patientId, date, diagnosis, visitCost) 1. For each doctor, list doctor identifier, doctor name and the total number of visits that were administered by the doctor. Solution Answer: select d.doctorId, d.doctorName, sum(p.numberOfVisits) from Doctors d, Patients p, Records r where d.doctorId = r.doctorId and r.patientId = p.patientId group by d.doctorId, d.doctorName;