{ "data": { "question": { "questionId": "1811", "questionFrontendId": "1667", "categoryTitle": "Database", "boundTopicId": 499879, "title": "Fix Names in a Table", "titleSlug": "fix-names-in-a-table", "content": "
Table: Users
\n+----------------+---------+\n| Column Name | Type |\n+----------------+---------+\n| user_id | int |\n| name | varchar |\n+----------------+---------+\nuser_id is the primary key (column with unique values) for this table.\nThis table contains the ID and the name of the user. The name consists of only lowercase and uppercase characters.\n\n\n
\n\n
Write a solution to fix the names so that only the first character is uppercase and the rest are lowercase.
\n\nReturn the result table ordered by user_id
.
The result format is in the following example.
\n\n\n
Example 1:
\n\n\nInput: \nUsers table:\n+---------+-------+\n| user_id | name |\n+---------+-------+\n| 1 | aLice |\n| 2 | bOB |\n+---------+-------+\nOutput: \n+---------+-------+\n| user_id | name |\n+---------+-------+\n| 1 | Alice |\n| 2 | Bob |\n+---------+-------+\n\n", "translatedTitle": "修复表中的名字", "translatedContent": "
表: Users
\n+----------------+---------+\n| Column Name | Type |\n+----------------+---------+\n| user_id | int |\n| name | varchar |\n+----------------+---------+\nuser_id 是该表的主键(具有唯一值的列)。\n该表包含用户的 ID 和名字。名字仅由小写和大写字符组成。\n\n\n
\n\n
编写解决方案,修复名字,使得只有第一个字符是大写的,其余都是小写的。
\n\n返回按 user_id
排序的结果表。
返回结果格式示例如下。
\n\n\n\n
示例 1:
\n\n\n输入:\nUsers table:\n+---------+-------+\n| user_id | name |\n+---------+-------+\n| 1 | aLice |\n| 2 | bOB |\n+---------+-------+\n输出:\n+---------+-------+\n| user_id | name |\n+---------+-------+\n| 1 | Alice |\n| 2 | Bob |\n+---------+-------+\n", "isPaidOnly": false, "difficulty": "Easy", "likes": 115, "dislikes": 0, "isLiked": null, "similarQuestions": "[]", "contributors": [], "langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}", "topicTags": [ { "name": "Database", "slug": "database", "translatedName": "数据库", "__typename": "TopicTagNode" } ], "companyTagStats": null, "codeSnippets": [ { "lang": "MySQL", "langSlug": "mysql", "code": "# Write your MySQL query statement below", "__typename": "CodeSnippetNode" }, { "lang": "MS SQL Server", "langSlug": "mssql", "code": "/* Write your T-SQL query statement below */", "__typename": "CodeSnippetNode" }, { "lang": "Oracle", "langSlug": "oraclesql", "code": "/* Write your PL/SQL query statement below */", "__typename": "CodeSnippetNode" }, { "lang": "Pandas", "langSlug": "pythondata", "code": "import pandas as pd\n\ndef fix_names(users: pd.DataFrame) -> pd.DataFrame:\n ", "__typename": "CodeSnippetNode" }, { "lang": "PostgreSQL", "langSlug": "postgresql", "code": "-- Write your PostgreSQL query statement below", "__typename": "CodeSnippetNode" } ], "stats": "{\"totalAccepted\": \"64.2K\", \"totalSubmission\": \"102K\", \"totalAcceptedRaw\": 64224, \"totalSubmissionRaw\": 102024, \"acRate\": \"62.9%\"}", "hints": [], "solution": null, "status": null, "sampleTestCase": "{\"headers\":{\"Users\":[\"user_id\",\"name\"]},\"rows\":{\"Users\":[[1,\"aLice\"],[2,\"bOB\"]]}}", "metaData": "{\"mysql\":[\"Create table If Not Exists Users (user_id int, name varchar(40))\"],\"mssql\":[\"Create table Users (user_id int, name varchar(40))\"],\"oraclesql\":[\"Create table Users (user_id int, name varchar(40))\"],\"database\":true,\"name\":\"fix_names\",\"pythondata\":[\"Users = pd.DataFrame([], columns=['user_id', 'name']).astype({'user_id':'Int64', 'name':'object'})\"],\"postgresql\":[\"\\nCreate table If Not Exists Users (user_id int, name varchar(40))\"],\"database_schema\":{\"Users\":{\"user_id\":\"INT\",\"name\":\"VARCHAR(40)\"}}}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [ "Create table If Not Exists Users (user_id int, name varchar(40))", "Truncate table Users", "insert into Users (user_id, name) values ('1', 'aLice')", "insert into Users (user_id, name) values ('2', 'bOB')" ], "enableRunCode": true, "envInfo": "{\"mysql\":[\"MySQL\",\"
\\u7248\\u672c\\uff1a mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\" Oracle Sql 11.2.<\\/p>\"],\"pythondata\":[\"Pandas\",\" Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"],\"postgresql\":[\"PostgreSQL\",\" PostgreSQL 16<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"Users\":[\"user_id\",\"name\"]},\"rows\":{\"Users\":[[1,\"aLice\"],[2,\"bOB\"]]}}",
"__typename": "QuestionNode"
}
}
}MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"