From cc1a057df8b81b82339824998ea55d73c4623049 Mon Sep 17 00:00:00 2001 From: ivanbyone Date: Tue, 8 Jul 2025 13:39:43 +0300 Subject: [PATCH] task: #1667 --- README.md | 1 + leetcode/easy/1667. Fix Names in a Table.sql | 26 ++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 leetcode/easy/1667. Fix Names in a Table.sql diff --git a/README.md b/README.md index 0addebd..2af3fde 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ Have a good contributing! - [1581. Customer Who Visited but Did Not Make Any Transactions](./leetcode/easy/1581.%20Customer%20Who%20Visited%20but%20Did%20Not%20Make%20Any%20Transactions.sql) - [1587. Bank Account Summary II](./leetcode/easy/1587.%20Bank%20Account%20Summary%20II.sql) - [1633. Percentage of Users Attended a Contest](./leetcode/easy/1633.%20Percentage%20of%20Users%20Attended%20a%20Contest.sql) + - [1667. Fix Names in a Table](./leetcode/easy/1667.%20Fix%20Names%20in%20a%20Table.sql) - [1683. Invalid Tweets](./leetcode/easy/1683.%20Invalid%20Tweets.sql) - [1693. Daily Leads and Partners](./leetcode/easy/1693.%20Daily%20Leads%20and%20Partners.sql) - [1729. Find Followers Count](./leetcode/easy/1729.%20Find%20Followers%20Count.sql) diff --git a/leetcode/easy/1667. Fix Names in a Table.sql b/leetcode/easy/1667. Fix Names in a Table.sql new file mode 100644 index 0000000..9d6976a --- /dev/null +++ b/leetcode/easy/1667. Fix Names in a Table.sql @@ -0,0 +1,26 @@ +/* +Question 1667. Fix Names in a Table +Link: https://leetcode.com/problems/fix-names-in-a-table/description/?envType=study-plan-v2&envId=top-sql-50 + +Table: Users + ++----------------+---------+ +| Column Name | Type | ++----------------+---------+ +| user_id | int | +| name | varchar | ++----------------+---------+ +user_id is the primary key (column with unique values) for this table. +This table contains the ID and the name of the user. The name consists of only lowercase and uppercase characters. + + +Write a solution to fix the names so that only the first character is uppercase and the rest are lowercase. + +Return the result table ordered by user_id. +*/ + +SELECT + user_id, + UPPER(SUBSTRING(name FROM 1 FOR 1)) || '' || LOWER(SUBSTRING(name FROM 2 FOR LENGTH(name))) AS name --noqa: RF04 +FROM Users +ORDER BY user_id