{ "data": { "question": { "questionId": "1670", "questionFrontendId": "1527", "boundTopicId": null, "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 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 an SQL query to report the patient_id, patient_name all conditions of 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 query 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": null, "translatedContent": null, "isPaidOnly": false, "difficulty": "Easy", "likes": 70, "dislikes": 121, "isLiked": null, "similarQuestions": "[]", "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\"]]}}", "categoryTitle": "Database", "contributors": [], "topicTags": [ { "name": "Database", "slug": "database", "translatedName": null, "__typename": "TopicTagNode" } ], "companyTagStats": null, "codeSnippets": [ { "lang": "MySQL", "langSlug": "mysql", "code": "# Write your MySQL query statement below\n", "__typename": "CodeSnippetNode" }, { "lang": "MS SQL Server", "langSlug": "mssql", "code": "/* Write your T-SQL query statement below */\n", "__typename": "CodeSnippetNode" }, { "lang": "Oracle", "langSlug": "oraclesql", "code": "/* Write your PL/SQL query statement below */\n", "__typename": "CodeSnippetNode" } ], "stats": "{\"totalAccepted\": \"20.2K\", \"totalSubmission\": \"41.8K\", \"totalAcceptedRaw\": 20193, \"totalSubmissionRaw\": 41811, \"acRate\": \"48.3%\"}", "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": "{\n \"mysql\": [\n \"Create table If Not Exists Patients (patient_id int, patient_name varchar(30), conditions varchar(100))\"\n ],\n \"mssql\": [\n \"Create table Patients (patient_id int, patient_name varchar(30), conditions varchar(100))\"\n ],\n \"oraclesql\": [\n \"Create table Patients (patient_id int, patient_name varchar(30), conditions varchar(100))\"\n ],\n \"database\": true\n}", "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, "enableTestMode": false, "enableDebugger": false, "envInfo": "{\"mysql\": [\"MySQL\", \"

MySQL 8.0.

\"], \"mssql\": [\"MS SQL Server\", \"

mssql server 2019.

\"], \"oraclesql\": [\"Oracle\", \"

Oracle Sql 11.2.

\"]}", "libraryUrl": null, "adminUrl": null, "challengeQuestion": null, "__typename": "QuestionNode" } } }