Class 12
Computer Science
Ch 3: Database and SQL
SQL DDL, DML Commands & Aggregate Functions
Structured Query Language (SQL) Commands
1. DDL (Data Definition Language):
CREATE TABLE Students (Roll INT PRIMARY KEY, Name VARCHAR(50), Marks DECIMAL(5,2));ALTER TABLE Students ADD (City VARCHAR(30));DROP TABLE Students;
2. DML (Data Manipulation Language):
INSERT INTO Students VALUES (101, 'Amit', 94.5);UPDATE Students SET Marks = 96.0 WHERE Roll = 101;DELETE FROM Students WHERE Roll = 101;
3. Querying with Aggregate Functions:
SELECT City, AVG(Marks) as AvgMarks, COUNT(*) as TotalStudents
FROM Students
WHERE Marks >= 60
GROUP BY City
HAVING COUNT(*) > 5
ORDER BY AvgMarks DESC; Practice Questions (1)
View All Chapter Q&AMultiple Choice Questions (1)
MCQ 2
+1.00 Mark
Which SQL clause is used to filter records resulting from a GROUP BY aggregation?
A
WHERE
B
HAVING
C
ORDER BY
D
LIKE
Correct:
Option B: HAVING
Explanation:
The HAVING clause was added to SQL because the WHERE keyword cannot be used with aggregate functions.