Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 26 additions & 0 deletions leetcode/easy/1667. Fix Names in a Table.sql
Original file line number Diff line number Diff line change
@@ -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