Test Index
CBSE Class 12 Computer Science 2025 Paper Compartment
© examsnet.com
Question : 32 of 37
Marks:
+1,
-0
Consider the table STAFF given below :Table : STAFF
(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 | STAFF_NAME | SALARY | DEPARTMENT | DESIGNATION |
| S101 | SUNITA | 26000 | MATHS | TGT |
| S201 | SUNIL | 80000 | COMMERCE | PGT |
| S301 | NEHA | 35000 | SCIENCE | TGT |
| S102 | MANJEET | 25000 | MATHS | TGT |
| S202 | MANNAN | 45000 | COMPUTER | TGT |
STAFF_ID : S333STAFF_NAME : GURMEETSALARY : 15000DEPARTMENT : ADMINDESIGNATION : 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 STAFFWHERE SALARY BETWEEN 25000 AND 30000;(II)
SELECT * FROM STAFF WHERE DEPARTMENT ="MATHS" AND SALARY > 25000;(III)
SELECT STAFF_NAME, STAFF_ID FROM STAFF WHEREDEPARTMENT LIKE "%S";(IV)
SELECT MAX(SALARY)FROM STAFF;
Solution:
(a)(I)
(II) MATHS staff with salary above 25000 (MANJEET has exactly 25000, so is left out):
(III)
(IV) Highest salary in the table:
SELECT DEPARTMENT, AVG(SALARY)FROM STAFFGROUP BY DEPARTMENT;(II)
INSERT INTO STAFFVALUES ('S333', 'GURMEET', 15000, 'ADMIN', 'CLERK');(III)SELECT DISTINCT DESIGNATION FROM STAFF;(IV)
SELECT * FROM STAFFWHERE 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 |
| STAFF_ID | STAFF_NAME | SALARY | DEPARTMENT | DESIGNATION |
| S101 | SUNITA | 26000 | MATHS | TGT |
"%S" means the department ends with S; only MATHS does:| STAFF_NAME | STAFF_ID |
| SUNITA | S101 |
| MANJEET | S102 |
| MAX(SALARY) |
| 80000 |
© examsnet.com
Go to Question: