DBMS – SQL Practice Queries
This section provides **hands-on SQL practice queries**
for students to improve **query writing skills**, **logic**,
and **exam performance**.
Assumed Table Structure
STUDENT -------------------------------- RollNo (INT, PK) Name (VARCHAR) CourseID (INT) Marks (INT) City (VARCHAR) COURSE -------------------------------- CourseID (INT, PK) CourseName (VARCHAR) Duration (INT)
1. Basic SELECT Queries
- Display all records from STUDENT table.
- Display only Name and Marks of students.
- Display distinct CourseID from STUDENT table.
- Display students whose marks are greater than 60.
2. WHERE Clause & Operators
- Display students from city 'Delhi'.
- Display students whose marks are between 50 and 80.
- Display students enrolled in CourseID 101 or 102.
- Display students whose name starts with 'A'.
3. ORDER BY & LIMIT
- Display students in descending order of marks.
- Display top 5 students based on marks.
- Display students ordered by name alphabetically.
4. Aggregate Functions
- Count total number of students.
- Find maximum and minimum marks.
- Find average marks of students.
- Find total marks obtained by all students.
5. GROUP BY & HAVING
- Count number of students in each course.
- Display courses having more than 5 students.
- Find average marks per course.
- Display courses where average marks > 60.
6. SQL Joins
- Display student name with course name.
- Display all students even if course is not assigned.
- Display all courses even if no student is enrolled.
7. Sub Queries
- Display student with highest marks.
- Display students scoring above average marks.
- Display students enrolled in longest duration course.
8. UPDATE & DELETE Queries
- Update marks of a student with RollNo = 5.
- Increase marks by 5 for all students.
- Delete students whose marks are less than 30.
9. Exam-Level Practice
- Write SQL query to display second highest marks.
- Write SQL query to find duplicate records.
- Write SQL query to find students not enrolled in any course.
- Write SQL query using JOIN and GROUP BY.
Practice Task
✔ Practice writing each query manually
✔ Test queries in MySQL / PostgreSQL
✔ Modify queries with different conditions
✔ Prepare for viva & lab exams
✔ Try converting queries into MCQs