0% found this document useful (0 votes)
41 views3 pages

Complete SQL Queries Class12

This document provides a comprehensive guide to SQL queries relevant for Class 12 Informatics Practices, including essential commands and example tables for practice. It covers various SQL operations such as SELECT, INSERT, UPDATE, DELETE, and JOIN, along with specific clauses and functions. The guide aims to help students prepare effectively for their exams by studying these queries thoroughly.

Uploaded by

pratham2211ps
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views3 pages

Complete SQL Queries Class12

This document provides a comprehensive guide to SQL queries relevant for Class 12 Informatics Practices, including essential commands and example tables for practice. It covers various SQL operations such as SELECT, INSERT, UPDATE, DELETE, and JOIN, along with specific clauses and functions. The guide aims to help students prepare effectively for their exams by studying these queries thoroughly.

Uploaded by

pratham2211ps
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

SQL Queries – Complete Guide for Class

12 Informatics Practices
This document contains all the important SQL queries that are commonly asked in Class 12
exams, along with example tables for practice. Study these carefully to cover the entire
syllabus.

Example Table: Students


Table: Students
+----+-------+----------+-------+-----------+
| ID | Name | Department | Marks | City |
+----+-------+----------+-------+-----------+
| 1 | Asha | CS | 85 | Mumbai |
| 2 | Rahul | IT | 75 | Pune |
| 3 | Meena | CS | 65 | Nashik |
| 4 | John | EC | 55 | Mumbai |
| 5 | Priya | IT | 45 | Pune |
+----+-------+----------+-------+-----------+

SQL Queries

1. SELECT Query
SELECT * FROM Students;

2. SELECT Specific Columns


SELECT Name, Marks FROM Students;

3. WHERE Clause
SELECT * FROM Students WHERE Marks > 60;

4. AND/OR Conditions
SELECT * FROM Students WHERE Department='CS' AND Marks > 60;

5. ORDER BY Clause
SELECT * FROM Students ORDER BY Marks DESC;

6. LIKE Operator
SELECT * FROM Students WHERE Name LIKE 'M%';
7. BETWEEN Operator
SELECT * FROM Students WHERE Marks BETWEEN 50 AND 80;

8. IN Operator
SELECT * FROM Students WHERE City IN ('Mumbai', 'Pune');

9. GROUP BY Clause
SELECT Department, AVG(Marks) FROM Students GROUP BY Department;

10. HAVING Clause


SELECT Department, AVG(Marks) FROM Students GROUP BY Department HAVING
AVG(Marks) > 60;

11. Aggregate Functions


SELECT COUNT(*), MAX(Marks), MIN(Marks), SUM(Marks), AVG(Marks) FROM Students;

12. INSERT INTO


INSERT INTO Students (ID, Name, Department, Marks, City) VALUES (6, 'Sara', 'CS', 78,
'Aurangabad');

13. UPDATE
UPDATE Students SET Marks = 90 WHERE ID = 1;

14. DELETE
DELETE FROM Students WHERE Marks < 50;

15. JOIN Example


SELECT S.Name, S.Department, M.Subject, M.Score FROM Students S INNER JOIN Marks M
ON S.ID = M.Student_ID;

16. UNION Example


SELECT Name FROM Students WHERE City = 'Mumbai' UNION SELECT Name FROM
Students WHERE City = 'Pune';

17. Subquery Example


SELECT * FROM Students WHERE Marks > (SELECT AVG(Marks) FROM Students);

18. EXISTS Example


SELECT * FROM Students S WHERE EXISTS (SELECT * FROM Marks M WHERE S.ID =
M.Student_ID AND M.Score > 70);

19. CASE Statement


SELECT Name, Marks, CASE WHEN Marks >= 60 THEN 'Pass' ELSE 'Fail' END AS Result
FROM Students;
20. DISTINCT Keyword
SELECT DISTINCT Department FROM Students;

You might also like