SQL assignment
Kashish Jain
121319085021
create database Kashish_21
Create Table Doctor
(Doct_ID int Primary Key, Doct_Name varchar(25) not null, Specialisation
varchar(25) unique not null);
Insert Into Doctor Values
(101,'Mittal','Cardiology'),
(201,'Arjun','Pediatrics'),
(301,'Chandrashekar','Opthamologyy'),
(401,'Yash','Endocrinology'),
(501,'Ravi Sharma','Radiology'),
(601,'Madhavi','Nephrology');
Select * from Doctor;
Select Doct_Name from Doctor where Doct_ID in(101,201,401);
Alter Table Doctor
Add Fees int;
Select * from Doctor;
Update Doctor set Fees=1745 where Doct_Id=101;
Update Doctor set Fees=1790 where Doct_Id=201;
Update Doctor set Fees=2610 where Doct_Id=301;
Update Doctor set Fees=1291 where Doct_Id=401;
Update Doctor set Fees=1477 where Doct_Id=501;
Update Doctor set Fees=1382 where Doct_Id=601;
Select * from Doctor;
Create Table Patient(Patient_Id Int Primary Key, Patient_Name varchar(20) not
null, Age int, AppointDate DATE, Doct_Id int Foreign Key references
Doctor(Doct_ID));
Insert into Patient values
(1001,'Ravi',29,'2001-08-22',101),
(1002,'Sam',68,'2002-05-12',201),
(1003,'Bob',60,'2001-06-11',301),
(1004,'Sita',55,'2002-06-11',401),
(1005,'Ram',38,'2001-06-11',501),
(1006,'Jessica',42,'2001-08-22',601);
Select * from Patient;
Select Patient_Name,AppointDate from Patient;
Select Patient_Name from Patient where Patient_Name like 'R%';
Select Max(Age) As Oldest_Patient_Age from Patient;
Select Patient_Name from Patient where Patient_Name like '___';
Doct_ID Doct_Name Specialisation Fees
1 101 Mittal Cardiology 1745
2 201 Arjun Pediatrics 1790
3 301 Chandrashekar Opthamologyy 2610
4 401 Yash Endocrinology 1291
5 501 Ravi Sharma Radiology 1477
6 601 Madhavi Nephrology 1382
Patient_Id Patient_Name Age AppointDate Doct_Id
1 1001 Ravi 29 22.08.2001 00:00:00 101
2 1002 Sam 68 12.05.2002 00:00:00 201
3 1003 Bob 60 11.06.2001 00:00:00 301
4 1004 Sita 55 11.06.2002 00:00:00 401
5 1005 Ram 38 11.06.2001 00:00:00 501
6 1006 Jessica 42 22.08.2001 00:00:00 601
LINK: https://rextester.com/KMJVE36780