SlideShare a Scribd company logo
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.pdf
archigallery1298
 
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
archigallery1298
 
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
archigallery1298
 
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
archigallery1298
 
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
archigallery1298
 
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
archigallery1298
 
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
archigallery1298
 
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
archigallery1298
 
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
archigallery1298
 
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
archigallery1298
 
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
archigallery1298
 
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
archigallery1298
 
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
archigallery1298
 
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
archigallery1298
 
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
archigallery1298
 
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
archigallery1298
 
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
archigallery1298
 
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
archigallery1298
 
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
archigallery1298
 
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
archigallery1298
 

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

The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 

Recently uploaded (20)

The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 

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;