SQL Quiz
Check what you have learned. All questions use the students and courses tables from this tutorial.
How the Quiz Works
Choose an answer for each question. The explanation tells you why it is right. If you miss one, go back to that lesson and try the examples again.
| id | name | city | age | marks | course_id |
|---|---|---|---|---|---|
| 1 | Ali Khan | Karachi | 19 | 78 | 1 |
| 2 | Ayesha Siddiqui | Lahore | 21 | 85 | 2 |
| 3 | Bilal Ahmed | Karachi | 22 | 64 | 1 |
| 4 | Fatima Noor | Islamabad | 20 | 92 | 3 |
| 5 | Hamza Raza | Karachi | 18 | 70 | NULL |
| 6 | Sana Iqbal | Lahore | 23 | 88 | 2 |
Question 1
Exercise
Which keyword reads data from a table?
Question 2
Exercise
How many rows does this return? SELECT name FROM students WHERE city = 'Karachi';
Question 3
Exercise
Which query shows the highest marks first?
Question 4
Exercise
What does SELECT AVG(marks) FROM students; return?
Question 5
Exercise
Which statement changes Ali Khan's marks to 80?
Question 6
Exercise
Which condition matches ages 19, 20 and 21?
Question 7
Exercise
An INNER JOIN between students and courses on students.course_id = courses.id returns how many rows?
Question 8
Exercise
Which clause filters groups after GROUP BY?
Question 9
Exercise
Which statement removes the whole students table, including its structure?
Question 10
Exercise
Which constraint makes a column both unique and not null, so it can identify each row?
What Next?
Well done on finishing the SQL tutorial. Now practise on a real database: continue with the MySQL tutorial or the PostgreSQL tutorial.
