24 To 26
24 To 26
(a) To show all the information about the patients of the cardiology department.
(b) To list the names of female patients who are either in the orthopaedic or surgery department.
(c) To list the name of all the patients with their date of admission in ascending order.
(d) To display the patient's name, charges, the age for female patients only.
(e) To count the number of patients with age > 30. ) To display various departments.
Answers
a) select * from hospital where
Department='Cardiology';
b) select name from hospital where Sex='F' and
Department in ('Cardiology', 'Surgery');
c) select name, DateofAdm from hospital order by
DateofAdm ;
d) select name, Charges, Age from hospital where
Sex='F';
e) select count (Age) from hospital where Age > 30;
f) select distinct (Department) from hospital:
g) select department, count(department) from
hospital group by department,
h) Create table Hospital( Pno Name Age Department
DateofAdm Charges Sex int(3) Primary Key, Varchar
(20), int (2), Varchar (15), date, int (4), char(1) ):
(25) Write SOL commands for the statements (a) to (g) on the table HOSPITAL.
(a)To display the details of all the patients whose name starts with the alphabet ‘Z'.
(e) To. add another column DocName(Doctor Name) of the type varchar in the above table.
(g)To decrease the charges by 5% of all the patients admitted to the ENT department.
Answers
(a) select* from hospital where name like “Z%”;
(b) update hospital set Age=20 where
Name='Kush':
(c) update hospital set Charges = Charges
(Charges *5)/100;
(d) delete from hospital where Name = 'Tarun':
(e) Alter table hospital add DocName varchar (20):
(f) select* from hospital where Age is NULL:
(g) update hospital set Charges = Charges-
(Charges*5) /100 where Department = “ENT”
Answers
(a) Insert into hospital values
(11,’kasif’,37,”ENT”,”2018-02-25,”M”)
(b) update hospital set Charges = NULL where
Department =”Surgery”;
(c) select *from hospital where charges between
300 and 400;
(d) select*from hospital where name like “_a%”;
(e) select sum (charges) from hospital where
Department = “ENT”
(f) select* from hospital where year(DateofAdm)
=2019;
(g) desc hospital;