Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

GD GOENKA PUBLIC SCHOOL MODEL TOWN

COMPUTER SCIENCE With PYTHON(083) : CLASS – XII

Ques : On the basis of given table - Hospital, write SQL Queries and give output :

1. Create the table Hospital with following constraints → No – Primary Key, Name not null, age > 10,
dateofadm default curdate, charges >=250, Sex (only M/F/O), Department not null
2. Insert the given records.
3. To show all info about patients of cardiology department.
4. To list the names of female patients who are either in ENT or Surgery department.
5. To list the names of all patients with their DateofAdmission in descending order.
6. To display the name, charges and age of patients whose names start with K.
7. To count the no, of patients with age greater than 30.
8. To display all the different departments
9. To display the min and max age of patients as per gender.
10. To display the department wise sum and average charges.
11. To display the number of patients in each department with more than 1 patient.
12. To change the age of patient Kush to 22.
13. To increase the charges of male patients of cardiology department by 10%.
14. To remove all records of female patients who paid charges between 300 and 400.
15. To add a new column – DocName varchar(20)
16. To rename the column Sex as Gender.
17. To display the structure of table Hospital
18. To display the first 4 characters of patients’ name.
19. To display the details of patients admitted in 1997.
20. To display all names and their length for age < 25.
Predict the output :
21. Select pow(4,3) , mod(37, 7) ;
22. Select round(1473.1457,2), round(1473.1457,-1), round(1473.1457)
23. Select name, Upper(Mid(name, 3,2)), length(name) from Hospital where department=’Eyes’ ;
24. Select instr(‘Maharaja Aggarsein’, ‘a’) ;
25. Select name, age from Hospital where year(DateofAdm) = 1997 ;
26. Select Department, avg(charges), min(charges) from Hospital group by Department;
27. Select Department, min(age), max(age) group by department having count(*) >2 ;
28. Select DateofAdm, month(DateofAdm) from Hospital where name like ’_u%’ ;
29. Select max(DateofAdm), min(DateofAdm) from Hospital;
30. Select date(now()), day(Curdate() ) ;

You might also like