Skip to content

Commit 404bdb3

Browse files
authored
Merge pull request #50 from iamAntimPal/Branch-1
Create 1527. Patients With a Condition.sql
2 parents a489aca + c120ccb commit 404bdb3

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
1527. Patients With a Condition
2+
Solved
3+
Easy
4+
Topics
5+
Companies
6+
SQL Schema
7+
Pandas Schema
8+
Table: Patients
9+
10+
+--------------+---------+
11+
| Column Name | Type |
12+
+--------------+---------+
13+
| patient_id | int |
14+
| patient_name | varchar |
15+
| conditions | varchar |
16+
+--------------+---------+
17+
patient_id is the primary key (column with unique values) for this table.
18+
'conditions' contains 0 or more code separated by spaces.
19+
This table contains information of the patients in the hospital.
20+
21+
22+
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.
23+
24+
Return the result table in any order.
25+
26+
The result format is in the following example.
27+
28+
29+
30+
Example 1:
31+
32+
Input:
33+
Patients table:
34+
+------------+--------------+--------------+
35+
| patient_id | patient_name | conditions |
36+
+------------+--------------+--------------+
37+
| 1 | Daniel | YFEV COUGH |
38+
| 2 | Alice | |
39+
| 3 | Bob | DIAB100 MYOP |
40+
| 4 | George | ACNE DIAB100 |
41+
| 5 | Alain | DIAB201 |
42+
+------------+--------------+--------------+
43+
Output:
44+
+------------+--------------+--------------+
45+
| patient_id | patient_name | conditions |
46+
+------------+--------------+--------------+
47+
| 3 | Bob | DIAB100 MYOP |
48+
| 4 | George | ACNE DIAB100 |
49+
+------------+--------------+--------------+
50+
Explanation: Bob and George both have a condition that starts with DIAB1.
51+
52+
53+
54+
# Write your MySQL query statement below
55+
SELECT patient_id, patient_name, conditions
56+
FROM Patients
57+
WHERE conditions LIKE 'DIAB1%' OR conditions LIKE '% DIAB1%'

0 commit comments

Comments
 (0)