Question
Write SQL 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.

Answer

(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) selectsum(Charges) from hospital where Department =’ ENT’;
(f) select* from hospital where year(DateofAdm)=2019;
(g) desc hospital;

(h)

Create table

Hospital (

Pno

int(3) Primary Key,

Name

Varchar(20),

Age

int(2),

Department

Varchar(15),

DateofAdm

date,

Charges

int(4),

Sex

char(1) );

Need a full question paper?

Generate a complete, print-ready paper with questions like this in minutes — across 16+ boards, with answer keys.

Start Generating Free