NAME: ROLL NO CS MONTHLY TEST OCTOBER 2022
SETA :
1. Write SQL commands to create the following table ( consider datatype and size of the columns by your own
, make slno as primary key and assign NOT NULL Constraint to name , check constraint to charge where
charge should be greater than or equal to 200 :
Based on above table write the sql commands for the following :(Q2 to 16 - one marks each)
2. To show all information about the patients of cardiology department.
3. To list the names of female patients who are in orthopedic dept
4. To list names of all patients with their date of admission in ascending order
5. To display Patient’s Name, Charges, age for male patients only.
6. To insert a new row in the HOSPITAL table wit the following:
11,”mustafa”,37,”ENT”,(25/02/98},250,”M”
7. To increase the charges of female employees working in ENT department by 25 %.
8. To display the detail of doctors whose name’s second character is ‘a’ and second last character is ‘n’;
9. To add a new column contact number in the hospital table with varchar datatype of size 10.
10. To display the structure of the table .
11. To display unique charges value of hospital table.
Write output for the following queries:
12. Select length(concat(name , department)) from hospital where month(dateofadm)=1;
13. Select upper(name) , upper(department) from hospital where age between 45 and 60;
14. Write degree and cardinality of above table.
15. Select charges*length(name) , upper(name) from hospital where length(name)>6;
16. Write degree and cardinality of the query:
Select length(concat(name , department)) from hospital where month(dateofadm)=1;
17. What do you mean by foreign key . Explain with a suitable example. 2
18. Which SQL command should be used to change the datatype of columns of a table. 1
—-----------------------------------------------------------------------------------------------------------------------------
NAME: ROLL NO CS MONTHLY TEST OCTOBER 2022
SET B
1. Write SQL command to create the following table EMployee(only structure , assume datatype and
columnsize by your own): 2
2. Write SQL command to remove all rows of employee table.
3. Write SQL command to change column name no by empno and set it as primary key.
4. Write SQL Command to insert at top 3 rows in the above given table.
5. To show all information about the employees of Engg. Branch.
6. To list the names of female employees who are in Science branch
7. To display Employee’s name , Salary ,Age for male employees only in ascending order of their age.
8. To list the names and department of all employees with their date of retirement in ascending order.
9. To display Employee’s name , annual Salary ,Age for female employees only where annual salary =
salary *12;
10. To display employee detail whose salary is greater than 2000 but less than 3000 .
11. To display a report of employee details with columns employee name , dateofrtd and department
for employees who are retiring in the year 98.
12. To delete the record of employee who belongs to science department.
13. To increase the salary of all female employees by 12000 who are about to retire in the month of
december.
14. Write SQL command to Display all the tables available in database ‘DB1’.
15. Write difference between DDL and DML commands. And also write two commands of each
category with their syntax; 2
Write output for below given queries:
16. Select upper(name) , age from employee where age in(32, 44,25);
17. Select name , age , salary + salary*12/100 as “increased salary” where department
in(‘engg.’,’estbl’) and name like ‘%j’;
18. Select no , name , age , department from employee where length(name)>6;
—------------------------------------------------------------------------------------------------------------
NAME: ROLL NO CS MONTHLY TEST OCTOBER 2022
SET C :
Write SQL commands for the following:
1. Write SQl command to create the above table assuming sno as primary key , average greater than 54 and
default div 1. 2
2. To view all the available databases.
3. To view distinct subject names of graduate table.
4. To display different divisions of graduate table.
5. Display details of graduates belongs to div 1 and average marks in the range 50 to 60.
6. To display graduates name and annual stipend of div 2 graduates belongs to mathematics subject.
7. To display a report of graduates with their name , stipend , subject and average marks in descending
order of stipend received by them.
8. To insert a new row in the GRADUATE table :
11,”KAJOL”,300,” COMPUTERS”,75,1
9. To increase the stipend of graduates belongs to computers subject by 50 %.
10. To delete the detail of graduates of chemistry subject for whom average marks is less than 60.
11. To display detail of graduates in descending order of average marks.
12. To insert a column address in the table with datatype varchar and size 60.
Write output for :
13. Select MIN(AVERAGE ) from GRADUATE where SUBJECT=”PHYSICS”;
14. Select SUM(STIPEND) from GRADUATE where DIV=1;
15. Select AVG(STIPEND) from GRADUATE where AVERAGE >=65;
16. Write the data type required for the field div.
17. Select mod(stipend , length(name)) as ‘mod2 result’ from graduates where div = 2;
18. What is significance of like operator and also write the uses of % and underscore operator with a suitable
sql command and its output. 2
—------------------------------------------------------------------------------------------------------------------------------------
NAME: ROLL NO CS MONTHLY TEST OCTOBER 2022
SET D
Write SQL Commands :
1. To create a database FUTURE DESIGNER
2. To activate the above database.
3. To create the above table with itemname as primary key , price should not be less than 5000 and default
discount 10. 2
4. To increase the discount of double bed furnitures by 20 % .
5. To delete the sofa furnitures with price below 9000 and discount only 10.
6. To display no , itemname and price of furnitures for which stock month is february and year is 2002 .
7. To display detail of interiors in descending order of price for which furniture type is either Office table or
Dining table.
8. to list ITEMNAME and TYPE of those items, in which DATEOFSTOCK is be 22/01/02 from the
INTERIORS table in descending order of ITEMNAME.
9. To display unique furniture types of interior table .
10. To remove the dateof stock column from interior table.
Write output for :
1. Select COUNT(distinct TYPE) from INTERIORS;
2. Select AVG(DISCOUNT) from INTERIORS where TYPE = “ Baby Cot”;
3. Select SUM(Price) from INTERIORS where DATOFSTOCK < ‘ 12/02/02’;
4. Select price*10/100 as “net discount” where type in (‘baby cot ‘,’sofa’);
5. Select concat(itemname,’is’ , type, ‘ of price ‘,price ,’and’ , discount) from interiors where itemname like
‘R%’ order by price;
6. Write difference between alter and update commands of mysql with suitable example. 2
7. What do you mean by a candidate key. Identify at least 4 possible candidate keys of the above table . 2
—---------------------------------------------------------------------------------------------------------------------------------------------------