Learn › Class 12 › Computer Science / Informatics Practices › Databases and SQL
Databases and SQL
Example 1: Top students, best first
Open one step at a time. Try the next step yourself first.
- Step 1. Table STUDENT(RollNo, Name, Class, Marks).
Show step 2
SELECT Name, Marks FROM STUDENT WHERE Marks > 80 ORDER BY Marks DESC;
Show step 3
Only rows with Marks above 80 appear, highest first.
Example 2: Average marks per class
Open one step at a time. Try the next step yourself first.
- Step 1. SELECT Class, AVG(Marks) FROM STUDENT GROUP BY Class;
Show step 2
Each class forms one group.
Show step 3
Add HAVING AVG(Marks) > 70 to keep only classes averaging above 70.