Number of Students per CollegeEasy

Number of Students per College

EasySQLPractice library · +10 XPgroup bysqlcounting

UptoSkills Arena is tracking student admissions. Given a list of student enrollments, determine how many students are associated with each college.

  • students table:
    • student_id (integer)
    • college_name (varchar(100))

Return the college_name and the count of students for each college. Order the results alphabetically by college_name.

If a college has no students, it should not appear in the result. Ties in student counts are not applicable here as we are just counting. Handle NULL college_name by excluding them from the count.

Tables

CREATE TABLE students (
  student_id integer PRIMARY KEY,
  college_name varchar(100)
);

Example data

INSERT INTO students (student_id, college_name) VALUES
(1, 'IIT Bombay'),
(2, 'IIT Bombay'),
(3, 'IIT Delhi'),
(4, 'IIT Madras'),
(5, 'IIT Bombay'),
(6, 'IIT Delhi'),
(7, 'IIT Guwahati'),
(8, NULL),
(9, 'IIT Madras'),
(10, 'IIT Delhi');

Your query is also checked on hidden datasets with different data.

Hints