0% found this document useful (0 votes)
31 views3 pages

24 To 26

Uploaded by

lokeshshukla191
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views3 pages

24 To 26

Uploaded by

lokeshshukla191
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

24) Write SOL commands for the statements (a) to (g) on the table HOSPITAL.

(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.

(g) To display the number of patients in each department.

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'.

(b) To change the age of the patient Kush to 20.

(c) To increase the charges of all the patients by 5%.

To remove the record of the patient whose Name is Tarun.

(e) To. add another column DocName(Doctor Name) of the type varchar in the above table.

(f) To display patient detail whose age is miss ing(null).

(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”

(26) Write SOL commands for the statements (a) to


(h) on the table HOSPITAL

(a) To insert a new row in the HOSPITAL table with


the following data: 11,' Kasif', 37, ENT', 2018 02-
25, 300, 'M’;
(b) To set charges to NULL for all the patients in
the Surgery department.
(c) To display patient details who are giving
charges in the range 300 and 400 (both
inclusive).
(d) To display the details of that patient whose
name second character contains a'.
(e) To display total charges of ENT Department.
(f) To display details of the patients who admitted
in the year 2019.
(g) To display the structure of the table hospital.
(h) Write the command to create the above table.

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;

You might also like