Format College NamesEasy

Format College Names

EasySQLPractice library · +10 XPstring functionssqlformatting

You are working for a national education portal that aggregates data from various colleges across India. The college names are entered inconsistently, with mixed cases. Your task is to standardize these names.

Tables:

  • colleges: college_id (integer, PK), college_name (varchar(100))

Return the college_name for all colleges, formatted such that the first letter of each word is capitalized and the rest are lowercase. The result should be ordered by college_id.

Handle NULLs by returning NULL. Empty results are possible if the table is empty. Ties in ordering are broken by college_id.

Tables

CREATE TABLE colleges (
  college_id integer PRIMARY KEY,
  college_name varchar(100)
);

Example data

INSERT INTO colleges (college_id, college_name) VALUES
(1, 'indian institute of technology'),
(2, 'DELHI UNIVERSITY'),
(3, 'National law school of india university'),
(4, 'iit bombay'),
(5, 'BITS Pilani');

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

Hints