Format Player NamesEasy

Format Player Names

EasySQLPractice library · +10 XPstring functionssqlformatting

A sports analytics company is preparing a dataset of cricket players for a new fantasy league. They need to standardize player names to ensure consistency.

Table: players

  • player_id (integer, PK)
  • full_name (varchar(100))

Return the player_id and the full_name formatted such that the first letter of each word in the name is capitalized, and the rest of the letters are lowercase. The output should be ordered by player_id.

Handle NULL full_name values by returning NULL for the formatted name. Empty results are possible if the players table is empty. Ties in formatted names are handled by the player_id ordering.

Tables

CREATE TABLE players (
  player_id integer PRIMARY KEY,
  full_name varchar(100)
);

Example data

INSERT INTO players (player_id, full_name) VALUES
(1, 'virat kohli'),
(2, 'ROHIT SHARMA'),
(3, 'sachin tendulkar'),
(4, 'MS DHONI'),
(5, 'sourav ganguly'),
(6, 'rahul dravid'),
(7, NULL),
(8, 'yuvraj singh');

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

Hints