Test Index
CBSE Class 12 Computer Science 2025 Paper Compartment
© examsnet.com
Question : 34 of 37
Marks:
+1,
-0
Assume that you are working for ABC Corporation (ABCC). ABCC allots contracts to different contractors for some of its works. The data of Contracts and Contractors are kept in the tables Work and Contractor respectively. Following are a few records from these two tables of ABCC’s database.Table : Work
Table : Contractor
Note : The tables contain many more records than shown here.As an employee of ABCC, you are required to write the SQL queries for the following :(I) To display all the records from the Work table in alphabetical order of W_Name.(II) To display the names of contractors where W_Amt is more than 15000.(III) To display the structure of Work table.(IV) (a) To count total number of records present in Work table.OR(b) To delete the records of contractors whose phone number is not known.
| W_ID | C_ID | W_Name | W_Amt |
| P0001 | C_01 | Painting | 20000 |
| E0001 | C_01 | Electrical | 50000 |
| D0001 | C_02 | Dumping | 10000 |
| C_ID | C_Name | Phone | |
| C_01 | M. Khan & Sons | 1232311 | MK@xyz.com |
| C_02 | Acharya Pvt. Ltd. | 2323311 | APL@xyz.com |
| C_03 | Charu Corp. | NULL | CCP@pqr.xyz |
Solution:
(I)
SELECT * FROM WorkORDER BY W_Name;(II) C_Name is in Contractor and W_Amt is in Work, so join the two tables on the common column C_ID:
SELECT C_NameFROM Work, ContractorWHERE Work.C_ID = Contractor.C_ID AND W_Amt > 15000;(Add DISTINCT after SELECT to show each contractor only once.)(III)
DESCRIBE Work;(or
DESC Work;)(IV) (a)SELECT COUNT(*) FROM Work;OR (b) An unknown phone number is stored as NULL, and NULL is tested with IS NULL (not = NULL):
DELETE FROM ContractorWHERE Phone IS NULL;
© examsnet.com
Go to Question: