0% found this document useful (0 votes)
7 views

MySql Board Assignment 2022 Class XII

Uploaded by

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

MySql Board Assignment 2022 Class XII

Uploaded by

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

MySQL Practical Questions

(2022-2023)

1. Create the table HOSPITAL with following structure:

Field Name DataType(Size) Constraint


No Integer Primary Key
Name Varchar(15) Not null
Age Integer
Department Varchar(15) Default ‘Surgery’
Dateofadm Date
Charges Integer >1000
Gender Varchar(1)

2. Consider the following table and write SQL commands for the queries for the questions

given from (a) to (e) and write the output of the SQL commands given from (f) to (h)

based on a relation HOSPITAL shown below :

No Name Age Department Dateofadm Charges Gender


1 Arpit 62 Surgery 2008-01-21 1300 M
2 Zarina 22 ENT 2007-12-12 1250 F
3 Kareem 32 Orthopaedic 2008-02-19 1200 M
4 Arun 12 Surgery 2008-01-11 1300 M
5 Zubin 30 ENT 2008-01-12 1250 M
6 Ketaki 16 ENT 2008-02-04 1250 F
7 Ankita 29 Cardiology 2007-02-20 1800 F
8 Zareen 45 Gynaecology 2008-02-10 1300 F
9 Kush 55 Cardiology 2008-01-13 1800 M
10 Shilpa 23 Nuclear 2008-02-21 1400 F
Medicine

(a) Insert the above two 2 tuples into the table.

(b)To display the details of patients who were admitted before 2008.

(c) To list Name and Age between the age of 40-60.

(d) To list names of all male patients with their date of admission in ascending order.

(e) To list all the details having Name’s last letter is ‘n’ belongs to ENT department.
(f) Increase the charges by 5% for all the patients whose Dateofadm is before 2008.

(g) Add another column BedNo with appropriate datatype into the table HOSPITAL.

(i) Delete primary key from the table HOSPITAL (Assume yourself the field which is

primary key.)

(f) Select * from HOSPITAL where department < > “Surgery” or gender < > “F”;

(g) Select age,charges from HOSPITAL where department NOT IN(‘Gynaecology’, ‘

Cardiology’);

(h) Select * from HOSPITAL where charges >=1300;

(i) Select Min(Dateofadm) from HOSPITAL ;


(j) Select Count(Department),Name from HOSPITAL Group By Department
Having Max(Age)>45;

(k) Select MOD (charges, DAY(Dateofadm)) FROM HOSPITAL WHERE Gender <> ‘F’;

(l) Select Count(Distinct charges ) FROM HOSPITAL;

3. Consider the table STUDENT given below:

RollNo Name Class DOB Gender City Marks


1 Anand XI 6/6/97 M Agra 430
2 Chetan XII 7/5/94 M Mumbai 460
3 Geet XI 6/5/97 F Agra 470
4 Preeti XII 8/8/95 F Mumbai 492
5 Saniyal XII 8/10/95 M Delhi 360
6 Manya XI 12/12/94 F Dubai 256
7 Neha X 8/12/95 F Moscow 324

8 Nishant X 12/6/95 M Moscow 429

(a)What will be the output of the following command?


Select * from student where gender =”F” order by marks desc ;

(b) Prachi has given the following command to obtain the highest marks :

Select max(marks) from student where group by class;


but she is not getting the desired result. Help her by writing the correct command.

(c) State the command to display the average marks scored by students of each gender

(d) Help Ritesh to write the command to display the name of the youngest student?
4. Consider a table SALESMAN with the following data:

SNO SNAME SALARY BONUS DATEOFJOIN


A01 Beena Mehta 30000 45.23 29-10-2019
A02 K. L. Sahay 50000 25.34 13-03-2018
B03 Nisha Thakkar 30000 35.00 18-03-2017
B04 LeelaYadav 80000 NULL 31-12-2018
C05 GautamGola 20000 NULL 23-01-1989
C06 TraptiGarg 70000 12.37 15-06-1987
D07 Neena Sharma 50000 27.89 18-03-1999
Write SQL queries using SQL functions to perform the following operations:
a) Display salesman name and bonus after rounding off to zero decimal places.
b) Display the position of occurrence of the string “ta” in salesman names.
c) Display the four characters from salesman name starting from second character.
d) Display the month name for the date of join of salesman.
e) Display the name of the weekday for the dateofjoin of salesman.

f) Double the Salary of Salesman for which Bonus is Null value.

5. Write the output produced by the following SQL commands:

(i) SELECT (POW(4,3) + LENGTH(56));

(ii) SELECT CONCAT("NIDA", " KAIFI") "FULL NAME";


(iii) SELECT YEAR(CURDATE()+10);
(iv) SELECT DAYOFYEAR(CURDATE()), DAYOFMONTH(CURDATE());
(v) SELECT LEFT("Unicode",3), RIGHT("Unicode",4);
(vi) SELECT INSTR("UNICODE","CO"), SUBSTR("Informatics Practices",3);
(vii) SELECT CONCAT(RIGHT(‘Welcome’, 4),MID(‘Let’s Play’,-4,6));

***********************

You might also like