Test Index

CBSE Class 12 Computer Science 2025 Paper Compartment Get it on Google PlayDownload on the App Store

© examsnet.com
Question : 32 of 37
Marks: +1, -0
Consider the table STAFF given below :
Table : STAFF
STAFF_IDSTAFF_NAMESALARYDEPARTMENTDESIGNATION
S101SUNITA26000MATHSTGT
S201SUNIL80000COMMERCEPGT
S301NEHA35000SCIENCETGT
S102MANJEET25000MATHSTGT
S202MANNAN45000COMPUTERTGT
(a) Write the suitable SQL queries to perform the following tasks :
(I) To display the average salary of each department.
(II) To insert the following record in the table, STAFF.
STAFF_ID      :  S333
STAFF_NAME : GURMEET
SALARY : 15000
DEPARTMENT : ADMIN
DESIGNATION : CLERK
(III) To display the unique designations from the table.
(IV) To display all the details of the staff whose name is of four letters.
OR
(b) Write the output for the queries given below :
(I)
SELECT STAFF_NAME FROM STAFF
WHERE SALARY BETWEEN 25000 AND 30000;
(II)
SELECT * FROM STAFF WHERE DEPARTMENT =
"MATHS" AND SALARY > 25000;
(III)
SELECT STAFF_NAME, STAFF_ID FROM STAFF WHERE
DEPARTMENT LIKE "%S";
(IV)
SELECT MAX(SALARY)FROM STAFF;
Solution:  
(a)
(I)
SELECT DEPARTMENT, AVG(SALARY)
FROM STAFF
GROUP BY DEPARTMENT;
(II)
INSERT INTO STAFF
VALUES ('S333', 'GURMEET', 15000, 'ADMIN', 'CLERK');
(III)
SELECT DISTINCT DESIGNATION FROM STAFF;
(IV)
SELECT * FROM STAFF
WHERE STAFF_NAME LIKE '____';
(The pattern has four underscores; each _ matches exactly one character. In the given data only NEHA has a four-letter name.)
OR (b)
(I) BETWEEN includes both limits, so salaries 26000 and 25000 qualify:
STAFF_NAME
SUNITA
MANJEET
(II) MATHS staff with salary above 25000 (MANJEET has exactly 25000, so is left out):
STAFF_IDSTAFF_NAMESALARYDEPARTMENTDESIGNATION
S101SUNITA26000MATHSTGT
(III) "%S" means the department ends with S; only MATHS does:
STAFF_NAMESTAFF_ID
SUNITAS101
MANJEETS102
(IV) Highest salary in the table:
MAX(SALARY)
80000
© examsnet.com
Advertisements
Go to Question: