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 System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education