Very Easy

Count entries in a table

Count the number of students in the students table. Assume that each row represents a unique student.

SCHEMA

students

+------------+------------+-----------+-----+------------+
| student_id | first_name | last_name | age | class_code |
+------------+------------+-----------+-----+------------+
| 1          | Mike       | Chaplin   | 12  | 7A         |
| 2          | Emily      | Jackson   | 12  | 7A         |
| 3          | Robert     | Jackson   | 12  | 7A         |
| ...        | ...        | ...       | ... | ...        |
+------------+------------+-----------+-----+------------+


EXPECTED OUTPUT
+--------------+
| num_students |
+--------------+
| 75           |
+--------------+

You can use COUNT(*) to count the number of rows in a table.

SELECT COUNT(*) AS num_students FROM students

  • This field is required.