{ "data": { "question": { "questionId": "1670", "questionFrontendId": "1527", "categoryTitle": "Database", "boundTopicId": 346927, "title": "Patients With a Condition", "titleSlug": "patients-with-a-condition", "content": "

Table: Patients

\n\n
\n+--------------+---------+\n| Column Name  | Type    |\n+--------------+---------+\n| patient_id   | int     |\n| patient_name | varchar |\n| conditions   | varchar |\n+--------------+---------+\npatient_id is the primary key (column with unique values) for this table.\n'conditions' contains 0 or more code separated by spaces. \nThis table contains information of the patients in the hospital.\n
\n\n

 

\n\n

Write a solution to find the patient_id, patient_name, and conditions of the patients who have Type I Diabetes. Type I Diabetes always starts with DIAB1 prefix.

\n\n

Return the result table in any order.

\n\n

The result format is in the following example.

\n\n

 

\n

Example 1:

\n\n
\nInput: \nPatients table:\n+------------+--------------+--------------+\n| patient_id | patient_name | conditions   |\n+------------+--------------+--------------+\n| 1          | Daniel       | YFEV COUGH   |\n| 2          | Alice        |              |\n| 3          | Bob          | DIAB100 MYOP |\n| 4          | George       | ACNE DIAB100 |\n| 5          | Alain        | DIAB201      |\n+------------+--------------+--------------+\nOutput: \n+------------+--------------+--------------+\n| patient_id | patient_name | conditions   |\n+------------+--------------+--------------+\n| 3          | Bob          | DIAB100 MYOP |\n| 4          | George       | ACNE DIAB100 | \n+------------+--------------+--------------+\nExplanation: Bob and George both have a condition that starts with DIAB1.\n
\n", "translatedTitle": "患某种疾病的患者", "translatedContent": "

患者信息表: Patients

\n\n
\n+--------------+---------+\n| Column Name  | Type    |\n+--------------+---------+\n| patient_id   | int     |\n| patient_name | varchar |\n| conditions   | varchar |\n+--------------+---------+\n在 SQL 中,patient_id (患者 ID)是该表的主键。\n'conditions' (疾病)包含 0 个或以上的疾病代码,以空格分隔。\n这个表包含医院中患者的信息。
\n\n

 

\n\n

查询患有 I 类糖尿病的患者 ID (patient_id)、患者姓名(patient_name)以及其患有的所有疾病代码(conditions)。I 类糖尿病的代码总是包含前缀 DIAB1 。

\n\n

任意顺序 返回结果表。

\n\n

查询结果格式如下示例所示。

\n\n

 

\n\n

示例 1:

\n\n
\n输入:\nPatients表:\n+------------+--------------+--------------+\n| patient_id | patient_name | conditions   |\n+------------+--------------+--------------+\n| 1          | Daniel       | YFEV COUGH   |\n| 2          | Alice        |              |\n| 3          | Bob          | DIAB100 MYOP |\n| 4          | George       | ACNE DIAB100 |\n| 5          | Alain        | DIAB201      |\n+------------+--------------+--------------+\n输出:\n+------------+--------------+--------------+\n| patient_id | patient_name | conditions   |\n+------------+--------------+--------------+\n| 3          | Bob          | DIAB100 MYOP |\n| 4          | George       | ACNE DIAB100 | \n+------------+--------------+--------------+\n解释:Bob 和 George 都患有代码以 DIAB1 开头的疾病。
\n", "isPaidOnly": false, "difficulty": "Easy", "likes": 102, "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 find_patients(patients: pd.DataFrame) -> pd.DataFrame:\n ", "__typename": "CodeSnippetNode" }, { "lang": "PostgreSQL", "langSlug": "postgresql", "code": "-- Write your PostgreSQL query statement below", "__typename": "CodeSnippetNode" } ], "stats": "{\"totalAccepted\": \"65.6K\", \"totalSubmission\": \"140.1K\", \"totalAcceptedRaw\": 65621, \"totalSubmissionRaw\": 140074, \"acRate\": \"46.8%\"}", "hints": [], "solution": null, "status": null, "sampleTestCase": "{\"headers\": {\"Patients\": [\"patient_id\", \"patient_name\", \"conditions\"]}, \"rows\": {\"Patients\": [[1, \"Daniel\", \"YFEV COUGH\"], [2, \"Alice\", \"\"], [3, \"Bob\", \"DIAB100 MYOP\"], [4, \"George\", \"ACNE DIAB100\"], [5, \"Alain\", \"DIAB201\"]]}}", "metaData": "{\"mysql\":[\"Create table If Not Exists Patients (patient_id int, patient_name varchar(30), conditions varchar(100))\"],\"mssql\":[\"Create table Patients (patient_id int, patient_name varchar(30), conditions varchar(100))\"],\"oraclesql\":[\"Create table Patients (patient_id int, patient_name varchar(30), conditions varchar(100))\"],\"database\":true,\"name\":\"find_patients\",\"pythondata\":[\"Patients = pd.DataFrame([], columns=['patient_id', 'patient_name', 'conditions']).astype({'patient_id':'int64', 'patient_name':'object', 'conditions':'object'})\"],\"postgresql\":[\"\\nCreate table If Not Exists Patients (patient_id int, patient_name varchar(30), conditions varchar(100))\"],\"database_schema\":{\"Patients\":{\"patient_id\":\"INT\",\"patient_name\":\"VARCHAR(30)\",\"conditions\":\"VARCHAR(100)\"}}}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [ "Create table If Not Exists Patients (patient_id int, patient_name varchar(30), conditions varchar(100))", "Truncate table Patients", "insert into Patients (patient_id, patient_name, conditions) values ('1', 'Daniel', 'YFEV COUGH')", "insert into Patients (patient_id, patient_name, conditions) values ('2', 'Alice', '')", "insert into Patients (patient_id, patient_name, conditions) values ('3', 'Bob', 'DIAB100 MYOP')", "insert into Patients (patient_id, patient_name, conditions) values ('4', 'George', 'ACNE DIAB100')", "insert into Patients (patient_id, patient_name, conditions) values ('5', 'Alain', 'DIAB201')" ], "enableRunCode": true, "envInfo": "{\"mysql\":[\"MySQL\",\"

\\u7248\\u672c\\uff1aMySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"

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\": {\"Patients\": [\"patient_id\", \"patient_name\", \"conditions\"]}, \"rows\": {\"Patients\": [[1, \"Daniel\", \"YFEV COUGH\"], [2, \"Alice\", \"\"], [3, \"Bob\", \"DIAB100 MYOP\"], [4, \"George\", \"ACNE DIAB100\"], [5, \"Alain\", \"DIAB201\"]]}}", "__typename": "QuestionNode" } } }