NEW
Font size
WorksheetsSQL Quiz: 25 MCQs on the Student Table
Total questions: 25
Worksheet time: 13mins
Which SQL statement retrieves all columns from the students table?
GET FROM students;
SELECT FROM students;
FETCH FROM students;
SHOW FROM students;
How can you retrieve only the names of all students?
SELECT Name FROM students;
SHOW Name FROM students;
EXTRACT Name FROM students;
DISPLAY Name FROM students;
Which clause is used to filter records based on a condition?
ORDER BY
WHERE
GROUP BY
HAVING
What will the following query return?
SELECT DISTINCT Department FROM students;
Number of departments
List of all unique departments
All student names
Count of students
Which query fetches students older than 21?
SELECT FROM students WHERE Age > 21;
SELECT FROM students WHERE Age >= 21;
SELECT FROM students HAVING Age > 21;
SELECT FROM students FILTER Age > 21;
How can you find students enrolled before 2023?
SELECT FROM students WHERE EnrollmentDate < '2023-01-01';
SELECT FROM students WHERE EnrollmentDate > '2023-01-01';
SELECT FROM students WHERE EnrollmentDate BETWEEN '2023-01-01' AND '2024-01-01';
SELECT FROM students ORDER BY EnrollmentDate;
Which SQL function counts the total number of students?
SUM(*)
COUNT(*)
TOTAL(*)
NUMBER(*)
Which query finds the youngest student?
SELECT MIN(Age) FROM students;
SELECT FROM students ORDER BY Age DESC LIMIT 1;
SELECT FROM students WHERE Age < 19;
SELECT Age FROM students GROUP BY MIN(Age);
How do you find students in the ‘Electronics’ department?
SELECT FROM students WHERE Department = 'Electronics';
SELECT FROM students WHERE Department LIKE 'Electronics';
SELECT FROM students HAVING Department = 'Electronics';
SELECT FROM students WHERE Department IN ('Electronics');
Which operator is used to filter students in multiple departments?
SELECT FROM students WHERE Department = 'Computer Science' AND 'Mechanical';
SELECT FROM students WHERE Department IN ('Computer Science', 'Mechanical');
SELECT FROM students WHERE Department OR 'Computer Science', 'Mechanical';
SELECT FROM students WHERE Department LIKE 'Computer Science', 'Mechanical';
Which query calculates the average age of students?
SELECT SUM(Age) FROM students;
SELECT AVG(Age) FROM students;
SELECT AVERAGE(Age) FROM students;
SELECT MEDIAN(Age) FROM students;
Which SQL query finds the second oldest student?
SELECT DISTINCT Age FROM students ORDER BY Age DESC LIMIT 1 OFFSET 1;
SELECT MAX(Age) FROM students LIMIT 1,1;
SELECT Age FROM students ORDER BY Age DESC SKIP 1 LIMIT 1;
SELECT SECOND(Age) FROM students;
Which SQL clause is used to group students by department?
GROUP BY
HAVING
ORDER BY
WHERE
Which SQL query counts the number of students in each department?
List of students
Count of students per department
All student names
Highest age in each department
Which query finds the number of male and female students?
SELECT Gender, COUNT(*) FROM students GROUP BY Gender;
SELECT COUNT(Gender) FROM students;
SELECT COUNT(*) WHERE Gender;
SELECT Gender COUNT FROM students;
What does UNION do?
Joins tables
Combines multiple SELECT queries without duplicates
Deletes duplicate records
Groups results
Which SQL command removes all records but keeps the structure?
DROP TABLE students;
TRUNCATE TABLE students;
DELETE FROM students;
REMOVE FROM students;
Which SQL query finds students who enrolled most recently?
SELECT * FROM students ORDER BY EnrollmentDate DESC LIMIT 1;
Oldest student
Student with the earliest enrollment date
Student with the most recent enrollment
Student with the highest age
What does the following query return?
SELECT Department, COUNT(*) FROM students GROUP BY Department HAVING COUNT(*) > 1;
Departments with more than one student
Total student count
Students older than 21
List of all students
Which SQL query finds duplicate ages?
SELECT Age, COUNT(*) FROM students GROUP BY Age HAVING COUNT(*) > 1;
Identifies duplicate ages
Counts unique ages
Lists all ages
Removes duplicate ages
Which SQL query finds students whose name contains 'a' anywhere in their name?
SELECT FROM students WHERE Name LIKE '%a%';
SELECT FROM students WHERE Name = 'a';
SELECT FROM students WHERE Name LIKE 'a%';
SELECT FROM students WHERE Name LIKE '_a_';
Which query retrieves students who have enrolled between January 2022 and December 2023?
SELECT FROM students WHERE EnrollmentDate BETWEEN '2022-01-01' AND '2023-12-31';
SELECT FROM students WHERE EnrollmentDate > '2022-01-01' OR EnrollmentDate < '2023-12-31';
SELECT FROM students WHERE EnrollmentDate = '2022-2023';
SELECT FROM students WHERE EnrollmentDate IN ('2022', '2023');
Which SQL query finds the number of students in each department and sorts the result in descending order?
SELECT Department, COUNT(*) FROM students GROUP BY Department ORDER BY COUNT(*) DESC;
SELECT COUNT(*) FROM students ORDER BY Department DESC;
SELECT Department, COUNT(*) FROM students SORT BY COUNT(*) DESC;
SELECT FROM students WHERE Department COUNT() DESC;
Which SQL function extracts the year from the EnrollmentDate column?
YEAR(EnrollmentDate)
EXTRACT(YEAR FROM EnrollmentDate)
DATE_PART('year', EnrollmentDate)
All of the above
Which SQL query finds the most recently enrolled student from the 'Computer Science' department?
SELECT FROM students WHERE Department = 'Computer Science' ORDER BY EnrollmentDate DESC LIMIT 1;
SELECT FROM students WHERE EnrollmentDate = MAX(EnrollmentDate) AND Department = 'Computer Science';
SELECT TOP 1 FROM students WHERE Department = 'Computer Science' ORDER BY EnrollmentDate DESC;
SELECT FROM students WHERE Department LIKE 'Computer Science' AND EnrollmentDate = (SELECT MAX(EnrollmentDate));
