Display the lowest and highest ages of patients treated by the doctor named "Joseph Lam'. Your answer Display the number of doctors in each specialty and the sum of their salaries. Your answer Display the number of hospitals in each city, and the sum of their capacities. Only display cities with more than 10 hospitals. Your answer

Database Systems: Design, Implementation, & Management
11th Edition
ISBN:9781285196145
Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Publisher:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Chapter7: Introduction To Structured Query Language (sql)
Section: Chapter Questions
Problem 21P: Write the SQL code to calculate the ASSIGN_CHARGE values in the ASSIGNMENT table in the...
icon
Related questions
Question
SQL Data Manipulation
Consider the following tables with sample data:
Hospital (hospitalNo, name, address, city, capacity)
Doctor
(doctorNo, name, specialty, salary, hospitalNo)
Patient (patientNo, name, phoneNo, age, doctor)
Hospital
hospitalNo
city capacity
address
1493 Cambridge St Boston
2 East 101st St New York 700
name
H117
Cambridge
600
H120
Mount Sinai
*******E
潮
...***
Doctor
cpecialty salary hospitalNo
| 180000
| 225000 H120
doctorNo
name
D201
Cardiologist
Robert Donald
Xin Wang
H117
D205
Neurologist
林
******
淋 琳
業
Patient
patientNo
P366
name phoneNo
Arthur Gluck
age doctor
D201
72
617-482-5801
P351
Lisa Hershman
212-353-1463 46
D205
Perform the following tasks using SQL statements:
Transcribed Image Text:SQL Data Manipulation Consider the following tables with sample data: Hospital (hospitalNo, name, address, city, capacity) Doctor (doctorNo, name, specialty, salary, hospitalNo) Patient (patientNo, name, phoneNo, age, doctor) Hospital hospitalNo city capacity address 1493 Cambridge St Boston 2 East 101st St New York 700 name H117 Cambridge 600 H120 Mount Sinai *******E 潮 ...*** Doctor cpecialty salary hospitalNo | 180000 | 225000 H120 doctorNo name D201 Cardiologist Robert Donald Xin Wang H117 D205 Neurologist 林 ****** 淋 琳 業 Patient patientNo P366 name phoneNo Arthur Gluck age doctor D201 72 617-482-5801 P351 Lisa Hershman 212-353-1463 46 D205 Perform the following tasks using SQL statements:
Display the lowest and highest ages of patients treated by the doctor named
"Joseph Lam'.
Your answer
Display the number of doctors in each specialty and the sum of their salaries.
Your answer
Display the number of hospitals in each city, and the sum of their capacities.
Only display cities with more than 10 hospitals.
Your answer
Transcribed Image Text:Display the lowest and highest ages of patients treated by the doctor named "Joseph Lam'. Your answer Display the number of doctors in each specialty and the sum of their salaries. Your answer Display the number of hospitals in each city, and the sum of their capacities. Only display cities with more than 10 hospitals. Your answer
Expert Solution
Step 1

CREATE TABLE patient(patientNo text PRIMARY KEY, name text, phoneNo text, age number, doctor text);

INSERT INTO patient VALUES('P1','Akshay','234-876-5673',12,'D5');
INSERT INTO patient VALUES('P2','Bhanu','987-654-2345',20,'D1');
INSERT INTO patient VALUES('P3','Chandler','345-765-1234',15,'D4');
INSERT INTO patient VALUES('P4','Rachel','345-876-5634',22,'D8');
INSERT INTO patient VALUES('P5','Ross','567-432-9616',30,'D5');
INSERT INTO patient VALUES('P6','Minoca','678-567-4321',28,'D1');
INSERT INTO patient VALUES('P7','Phoebe','876-453-3852',18,'D5');
INSERT INTO patient VALUES('P8','Gunther','984-345-2876',13,'D6');
INSERT INTO patient VALUES('P9','Mark','809-501-2354',21,'D9');
INSERT INTO patient VALUES('P10','Joey','123=765-9254',25,'D5');

select min(age), max(age)
from doctor d join patient p
where d.doctorNo = p.doctor and
d.name = 'Joseph Lam';

Computer Science homework question answer, step 1, image 1

 

CREATE TABLE doctor(doctorNo integer PRIMARY KEY, name text, speciality text, salary text, hospitalNo text);

INSERT INTO doctor VALUES(1,'Aman','cardiologist',120000,'H12');
INSERT INTO doctor VALUES(2,'Bhav','neurologist',200000,'H12');
INSERT INTO doctor VALUES(3,'Chan','cardiologist',150000,'H1');
INSERT INTO doctor VALUES(4,'Dimple','neurologist',225000,'H16');
INSERT INTO doctor VALUES(5,'Joseph Lam','dermitologist',155000,'H3');
INSERT INTO doctor VALUES(6,'Green','dermitologist',200000,'H6');
INSERT INTO doctor VALUES(7,'Gurpreet','dermitologist',185000,'H10');
INSERT INTO doctor VALUES(8,'Harpreet','gynocologist',135000,'H6');
INSERT INTO doctor VALUES(9,'Inder','cardiologist',215000,'H9');
INSERT INTO doctor VALUES(10,'Jass','neurologist',125000,'H15');

select speciality, count(speciality), sum(salary)
from doctor
group by speciality;

 

Computer Science homework question answer, step 1, image 2

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Types of trees
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781285196145
Author:
Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Publisher:
Cengage Learning
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781305627482
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
CMPTR
CMPTR
Computer Science
ISBN:
9781337681872
Author:
PINARD
Publisher:
Cengage