wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

SQL Quiz: 25 MCQs on the Student Table

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

Which SQL statement retrieves all columns from the students table?

a)
  • GET FROM students;

b)

  • SELECT
    FROM students;

c)

  • FETCH FROM students;

d)
  • SHOW FROM students;

2.

How can you retrieve only the names of all students?

a)

SELECT Name FROM students;

b)

SHOW Name FROM students;

c)

EXTRACT Name FROM students;

d)

DISPLAY Name FROM students;

3.

Which clause is used to filter records based on a condition?

a)

ORDER BY

b)

WHERE

c)

GROUP BY

d)

HAVING

4.

What will the following query return?

SELECT DISTINCT Department FROM students;

a)

Number of departments

b)

List of all unique departments

c)

All student names

d)

Count of students

5.

Which query fetches students older than 21?

a)

SELECT FROM students WHERE Age > 21;

b)

SELECT FROM students WHERE Age >= 21;

c)

SELECT FROM students HAVING Age > 21;

d)

SELECT FROM students FILTER Age > 21;

6.

How can you find students enrolled before 2023?

a)

SELECT FROM students WHERE EnrollmentDate < '2023-01-01';

b)

SELECT FROM students WHERE EnrollmentDate > '2023-01-01';

c)

SELECT FROM students WHERE EnrollmentDate BETWEEN '2023-01-01' AND '2024-01-01';

d)

SELECT FROM students ORDER BY EnrollmentDate;

7.

Which SQL function counts the total number of students?

a)

SUM(*)

b)

COUNT(*)

c)

TOTAL(*)

d)

NUMBER(*)

8.

Which query finds the youngest student?

a)

SELECT MIN(Age) FROM students;

b)

SELECT FROM students ORDER BY Age DESC LIMIT 1;

c)

SELECT FROM students WHERE Age < 19;

d)

SELECT Age FROM students GROUP BY MIN(Age);

9.

How do you find students in the ‘Electronics’ department?

a)

SELECT FROM students WHERE Department = 'Electronics';

b)

SELECT FROM students WHERE Department LIKE 'Electronics';

c)

SELECT FROM students HAVING Department = 'Electronics';

d)

SELECT FROM students WHERE Department IN ('Electronics');

10.
  1. Which operator is used to filter students in multiple departments?

a)
  1. SELECT FROM students WHERE Department = 'Computer Science' AND 'Mechanical';

b)
  1. SELECT FROM students WHERE Department IN ('Computer Science', 'Mechanical');

c)
  1. SELECT FROM students WHERE Department OR 'Computer Science', 'Mechanical';

d)
  1. SELECT FROM students WHERE Department LIKE 'Computer Science', 'Mechanical';

11.

Which query calculates the average age of students?

a)

SELECT SUM(Age) FROM students;

b)

SELECT AVG(Age) FROM students;

c)

SELECT AVERAGE(Age) FROM students;

d)

SELECT MEDIAN(Age) FROM students;

12.

Which SQL query finds the second oldest student?

a)

SELECT DISTINCT Age FROM students ORDER BY Age DESC LIMIT 1 OFFSET 1;

b)

SELECT MAX(Age) FROM students LIMIT 1,1;

c)

SELECT Age FROM students ORDER BY Age DESC SKIP 1 LIMIT 1;

d)

SELECT SECOND(Age) FROM students;

13.

Which SQL clause is used to group students by department?

a)

GROUP BY

b)

HAVING

c)

ORDER BY

d)

WHERE

14.

Which SQL query counts the number of students in each department?

a)

List of students

b)

Count of students per department

c)

All student names

d)

Highest age in each department

15.

Which query finds the number of male and female students?

a)

SELECT Gender, COUNT(*) FROM students GROUP BY Gender;

b)

SELECT COUNT(Gender) FROM students;

c)

SELECT COUNT(*) WHERE Gender;

d)

SELECT Gender COUNT FROM students;

16.

What does UNION do?

a)

Joins tables

b)

Combines multiple SELECT queries without duplicates

c)

Deletes duplicate records

d)

Groups results

17.

Which SQL command removes all records but keeps the structure?

a)

DROP TABLE students;

b)

TRUNCATE TABLE students;

c)

DELETE FROM students;

d)

REMOVE FROM students;

18.

Which SQL query finds students who enrolled most recently?

SELECT * FROM students ORDER BY EnrollmentDate DESC LIMIT 1;

a)

Oldest student

b)

Student with the earliest enrollment date

c)

Student with the most recent enrollment

d)

Student with the highest age

19.
  • What does the following query return?

    SELECT Department, COUNT(*) FROM students GROUP BY Department HAVING COUNT(*) > 1;

a)
  • Departments with more than one student

b)
  • Total student count

c)
  • Students older than 21

d)
  • List of all students

20.

Which SQL query finds duplicate ages?

SELECT Age, COUNT(*) FROM students GROUP BY Age HAVING COUNT(*) > 1;

a)

Identifies duplicate ages

b)

Counts unique ages

c)

Lists all ages

d)

Removes duplicate ages

21.

Which SQL query finds students whose name contains 'a' anywhere in their name?

a)

SELECT FROM students WHERE Name LIKE '%a%';

b)

SELECT FROM students WHERE Name = 'a';

c)

SELECT FROM students WHERE Name LIKE 'a%';

d)

SELECT FROM students WHERE Name LIKE '_a_';

22.

Which query retrieves students who have enrolled between January 2022 and December 2023?

a)

SELECT FROM students WHERE EnrollmentDate BETWEEN '2022-01-01' AND '2023-12-31';

b)

SELECT FROM students WHERE EnrollmentDate > '2022-01-01' OR EnrollmentDate < '2023-12-31';

c)

SELECT FROM students WHERE EnrollmentDate = '2022-2023';

d)

SELECT FROM students WHERE EnrollmentDate IN ('2022', '2023');

23.

Which SQL query finds the number of students in each department and sorts the result in descending order?

a)

SELECT Department, COUNT(*) FROM students GROUP BY Department ORDER BY COUNT(*) DESC;

b)

SELECT COUNT(*) FROM students ORDER BY Department DESC;

c)

SELECT Department, COUNT(*) FROM students SORT BY COUNT(*) DESC;

d)

SELECT FROM students WHERE Department COUNT() DESC;

24.

Which SQL function extracts the year from the EnrollmentDate column?

a)

YEAR(EnrollmentDate)

b)

EXTRACT(YEAR FROM EnrollmentDate)

c)

DATE_PART('year', EnrollmentDate)

d)

All of the above

25.

Which SQL query finds the most recently enrolled student from the 'Computer Science' department?

a)

SELECT FROM students WHERE Department = 'Computer Science' ORDER BY EnrollmentDate DESC LIMIT 1;

b)

SELECT FROM students WHERE EnrollmentDate = MAX(EnrollmentDate) AND Department = 'Computer Science';

c)

SELECT TOP 1 FROM students WHERE Department = 'Computer Science' ORDER BY EnrollmentDate DESC;

d)

SELECT FROM students WHERE Department LIKE 'Computer Science' AND EnrollmentDate = (SELECT MAX(EnrollmentDate));