Easy
Find youngest students
Find the two youngest students in the students
table.
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
+------------+------------+-----------+-----+------------+
| student_id | first_name | last_name | age | class_code |
+------------+------------+-----------+-----+------------+
| 7 | Samantha | Smith | 9 | 7A |
| 8 | Adbul | Rahim | 9 | 7A |
+------------+------------+-----------+-----+------------+
Use ORDER BY
to sort the students by age.
Use LIMIT
to specify the number of rows you want to show. For example, appending LIMIT 5
to the end of your query will result in the first five rows being returned.
SELECT *
FROM students
ORDER BY age ASC
LIMIT 2