0% found this document useful (0 votes)
16 views4 pages

Quick SQL Commands Revision Class 12

The SQL Revision Tutorial is structured into an introduction to SQL, key SQL commands, aggregate functions, and practice questions, totaling one hour. It covers essential SQL concepts including DDL, DML, and TCL, along with practical examples and a sample 'Students' table. The session concludes with hands-on practice questions to reinforce learning.

Uploaded by

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

Quick SQL Commands Revision Class 12

The SQL Revision Tutorial is structured into an introduction to SQL, key SQL commands, aggregate functions, and practice questions, totaling one hour. It covers essential SQL concepts including DDL, DML, and TCL, along with practical examples and a sample 'Students' table. The session concludes with hands-on practice questions to reinforce learning.

Uploaded by

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

SQL Revision Tutorial (1 Hour)

Session Plan

Introduction (5 mins) – Overview of SQL

SQL Commands (25 mins) – Key commands with examples

Aggregate Functions (20 mins) – Explanation with queries

Practice Questions (10 mins) – Hands-on revision

---

1. Introduction to SQL (5 mins)

SQL (Structured Query Language) is used to interact with databases.

Databases store structured data in tables (rows & columns).

SQL is categorized into:

DDL (Data Definition Language): CREATE, ALTER, DROP

DML (Data Manipulation Language): SELECT, INSERT, UPDATE, DELETE

DCL (Data Control Language): GRANT, REVOKE

TCL (Transaction Control Language): COMMIT, ROLLBACK

---

2. Practice Table: Students

Before practicing the commands, create the following table and insert sample data:

CREATE TABLE Students (


ID INT PRIMARY KEY,
Name VARCHAR(50),
Age INT,
Marks FLOAT,
City VARCHAR(30)
);

INSERT INTO Students (ID, Name, Age, Marks, City) VALUES


(1, 'Rahul', 17, 89.5, 'Delhi'),
(2, 'Aisha', 18, 76.0, 'Mumbai'),
(3, 'Vikram', 17, 92.3, 'Delhi'),
(4, 'Sara', 18, 85.4, 'Kolkata'),
(5, 'Kabir', 17, 95.0, 'Mumbai');

---

3. Important SQL Commands (25 mins)

(a) Data Definition Language (DDL)

ALTER TABLE Students ADD COLUMN Phone VARCHAR(15);

DROP TABLE Students;

(b) Data Manipulation Language (DML)

INSERT INTO Students (ID, Name, Age, Marks, City) VALUES (6, 'Neha', 18, 88.2, 'Chennai');

UPDATE Students SET Marks = 92 WHERE ID = 1;

DELETE FROM Students WHERE ID = 1;

(c) Data Query Language (DQL)

SELECT * FROM Students;

SELECT Name, Marks FROM Students WHERE Marks > 80;

SELECT Name, Marks FROM Students ORDER BY Marks DESC;

SELECT * FROM Students LIMIT 5;

---
4. SQL Aggregate Functions (20 mins)

(a) COUNT() - Count total rows

SELECT COUNT(*) FROM Students;

(b) SUM() - Total of a column

SELECT SUM(Marks) FROM Students;

(c) AVG() - Average of a column

SELECT AVG(Marks) FROM Students;

(d) MAX() - Highest value

SELECT MAX(Marks) FROM Students;

(e) MIN() - Lowest value

SELECT MIN(Marks) FROM Students;

(f) GROUP BY - Group data by a column

SELECT City, AVG(Marks) FROM Students GROUP BY City;

(g) HAVING - Filtering groups

SELECT City, AVG(Marks) FROM Students GROUP BY City HAVING AVG(Marks) > 85;

---

5. Practice Questions (10 mins)

1. Write an SQL query to count the number of students.

2. Find the average marks of students in a specific city.

3. Retrieve the names of students who scored above 90.


4. Find the student with the highest marks.

5. Display the total marks of all students.

---

This tutorial provides a quick and effective revision.

You might also like