My CS Tutorial

info.mycstutorial@gmail.com | +91 82 21 90 90 45

SQL DML and SELECT Queries Practice Worksheets for Class XII (With Answers)

SQL DML and SELECT Queries Practice Worksheets for Class XII (With Answers)

Are you studying Structured Query Language (SQL) for your Class XII Computer Science or Informatics Practices curriculum? To master database manipulation and data retrieval, practice is key! Below, you will find five comprehensive sets of worksheets focusing on Data Manipulation Language (DML), the SELECT statement, operators, clauses, handling NULL values, pattern matching (`LIKE`), UPDATE, DELETE commands, and aggregate functions.

Each set contains 10 practice questions. Click the “Show Answer Key” button under each worksheet to check your solutions and review the code examples.

Worksheet Set 1: Basic SELECT, Operators, Aliasing & DISTINCT

COMPUTER SCIENCE / INFORMATICS PRACTICES

SQL Worksheet Set 1: Basic SELECT, Operators, Aliasing & DISTINCT

Name: ________________________ Roll No: _________ Date: ____________

Q1. Write a query to display all records and columns from a table named Employee.

Q2. Consider a table Employee with columns EmpName and Salary. Write a query to display each employee’s name and their calculated annual salary under an alias AnnualSalary (Salary * 12).

Q3. Write a query to display the unique job titles from the Job column in an Employee table without duplicate rows.

Q4. Evaluate the mathematical query output: SELECT 15 + 4 * 3 - 2;.

Q5. Write a query to display only the ItemName and Price columns from a table named Product.

Q6. Given a table Staff with columns Name and Bonus, write a query to display staff names and an alias column NetBonus calculated by adding 500 to their current bonus.

Q7. Write a query to retrieve distinct departments from a Department column in a table named Worker.

Q8. What will be the output of the query: SELECT 50 / 5 + 10;?

Q9. Consider a table Item with columns ItemName and Price. Write a query to display item names and a discounted price column named DiscPrice computed as Price * 0.90.

Q10. Write a query to display unique grades secured by students from a Student table.

Worksheet Set 2: WHERE Clause, Relational/Logical Operators, BETWEEN, IN & ORDER BY

COMPUTER SCIENCE / INFORMATICS PRACTICES

SQL Worksheet Set 2: WHERE Clause, Operators, BETWEEN, IN & ORDER BY

Name: ________________________ Roll No: _________ Date: ____________

Q1. Write a query to display all details of students from a Student table where Stream is ‘Science’ and Marks are greater than 85.

Q2. Write a query to fetch details of employees whose salary is either 25000, 30000, or 45000 using the IN operator.

Q3. Write a query to display products whose price falls between 100 and 500 (inclusive) using the BETWEEN operator.

Q4. Write a query to list all employee records from a table Staff sorted in descending order of their JoiningDate.

Q5. Write a query to display items whose category is ‘Electronics’ and price is not greater than 2000.

Q6. Write a query to display student names and marks where marks are less than 40 or greater than 90.

Q7. Write a query to list employees working in either ‘HR’, ‘IT’, or ‘Finance’ departments using the IN operator.

Q8. Write a query to display all book details sorted alphabetically by their Title column.

Q9. Write a query to fetch records of customers whose age is between 20 and 30 using the BETWEEN operator.

Q10. Write a query to display items whose quantity is greater than or equal to 50, ordered by quantity in ascending order.

Worksheet Set 3: Handling NULL Values & Pattern Matching with LIKE

COMPUTER SCIENCE / INFORMATICS PRACTICES

SQL Worksheet Set 3: Handling NULL Values & Pattern Matching (LIKE)

Name: ________________________ Roll No: _________ Date: ____________

Q1. Explain what a NULL value signifies in a relational database table.

Q2. Write a query to display the names of employees whose Commission column contains a NULL value.

Q3. Write a query to list all books from a Book table where the phone number is not missing (i.e., not null).

Q4. Write a query to display the names of all students starting with the letter ‘A’.

Q5. Write a query to find all items where the second character of the item name is ‘u’.

Q6. Write a query to display employee names whose names end with the letter ‘n’.

Q8. Write a query to find customer accounts where the email address is missing (null).

Q9. Write a query to list products where the description column is not empty/null.

Q10. Write a query to display names of employees starting with ‘S’ and ending with ‘h’.

Worksheet Set 4: UPDATE & DELETE Commands

COMPUTER SCIENCE / INFORMATICS PRACTICES

SQL Worksheet Set 4: UPDATE & DELETE Commands

Name: ________________________ Roll No: _________ Date: ____________

Q1. Write a query to update the salary of all employees to 50000 in the Employee table.

Q2. Write a query to increase the price of all items by 10% in the Inventory table where the category is ‘Stationery’.

Q3. Write a query to change the department to ‘HR’ and raise the salary by 5000 for an employee whose EmpID is 102.

Q4. Write a query to delete all records from a table named TempLogs.

Q5. Write a query to delete records from the Student table where attendance is less than 40.

Q6. Write a query to update email to ‘Not Provided’ where the email column is NULL in a User table.

Q7. Write a query to delete products from an Inventory table where stock quantity is 0.

Q8. Write a query to update account status to ‘Active’ for all customers whose age is greater than or equal to 18.

Q9. Write a query to delete employees from a Staff table who belong to the ‘Temporary’ department.

Q10. Write a query to set a discount percentage to 5 for all items whose price exceeds 1000.

Worksheet Set 5: Aggregate Functions & Mixed Queries

COMPUTER SCIENCE / INFORMATICS PRACTICES

SQL Worksheet Set 5: Aggregate Functions & Mixed Queries

Name: ________________________ Roll No: _________ Date: ____________

Q1. Write a query to find the total number of rows/records in the Customer table.

Q2. Write a query to display the maximum and minimum salary earned by any employee in the Staff table.

Q3. Write a query to calculate the average price of all products available in the Product table.

Q4. Write a query to find the total sum of salaries paid to employees working in the ‘Sales’ department.

Q5. What is the core behavior of aggregate functions when encountering NULL values in a column?

Q6. Write a query to count the total number of students enrolled in the ‘Commerce’ stream.

Q7. Write a query to find the highest marks obtained by any student in the Exam table.

Q8. Write a query to find the lowest price among items belonging to the ‘Grocery’ category.

Q9. Write a query to calculate the average age of employees working in the ‘HR’ department.

Q10. Write a query to calculate the total ordered quantity across all transactions in an Orders table.


By Anjeev Kr Singh – Computer Science Educator
Published on : September 18, 2026 | Updated on : September 18, 2026

About the Author

Anjeev Kr Singh

Anjeev Kr Singh

Computer Science Educator, Author, and HOD. Guiding CBSE students in CS, IP, IT, WA & AI via mycstutorial.in. Creator of Question Bank for Class 10 & 12 students.

You cannot copy content of this page

Scroll to Top