Question: 1 . Create a a database DB _ consultation 2 . Create the following tables Patient ( PatientID , Name, Age, Gender ) Doctor (
Create a a database DBconsultation
Create the following tables
Patient PatientID Name, Age, Gender
Doctor DoctorID Name, Speciality
Treatment TreatmentID, DoctorID, PatientID, Natureoftreatment, Dateoftreatment
Add field salary to Doctor Table.
Insert values in the tables
Write an SQL statement to display all the data from Doctor Table.
Write an SQL statement to display all the records from Doctor and sort them in a descending order
Write an SQL statement to display doctors earning a salary between and
Write an SQL statement to display the total salary of the doctors.
Solutions
Create database DBconsultation
Create table Patient
PatientID int CONSTRAINT pkPatientID Primary key,
Patname varchar Not null,
Age int not null,
Gender varchar ;
Create table Doctor
DoctorID int CONSTRAINT pkDoctorID Primary key,
Docname varchar Not null,
Speciality varchar not null;
Create table treatment
TreatmentID int CONSTRAINT pkTreatmentID Primary key,
DoctorID int Foreign Key References DoctorDoctorID
PatientID int Foreign Key References PatientPatientID
Natureoftreatment varchar Not Null,
Dateoftreatment Date;
Add field salary to Doctor Table.
ALTER TABLE Doctor
ADD salary money not null;
Insert values in the tables
INSERT into Doctor
values 'Sara Adams', 'General', ;
INSERT into Doctor
values 'Mary jones', 'Dentist', ;
INSERT into Doctor
values 'Wiliam Prince', 'Cardiologist', ;
INSERT into Doctor
values 'Mary Charles', 'Residence Doctor', ;
INSERT into Doctor
values 'Charles Adams', 'General', ;
Write an SQL statement to display all the data from Doctor table
SELECT From Doctor
Write an SQL statement to display all the records from Doctor and sort them in a descending order
SELECT From Doctor ORDER BY DoctorID DESC;
Write an SQL statement to display doctors earning a salary between and
SELECT FROM DOCTOR WHERE salary BETWEEN AND ;
Write an SQL statement to display the total salary of the doctors.
SELECT SUMsalary FROM Doctor
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
