From c5228f2488aefeab8bec412932ecd1fe5d8beeaa Mon Sep 17 00:00:00 2001 From: ivanbyone Date: Tue, 8 Jul 2025 15:10:44 +0300 Subject: [PATCH] task: #1527 --- README.md | 1 + .../easy/1527. Patients With a Condition.sql | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 leetcode/easy/1527. Patients With a Condition.sql diff --git a/README.md b/README.md index 2af3fde..ca188b7 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ Have a good contributing! - [1378. Replace Employee ID With The Unique Identifier](./leetcode/easy/1378.%20Replace%20Employee%20ID%20With%20The%20Unique%20Identifier.sql) - [1407. Top Travellers](./leetcode/easy/1407.%20Top%20Travellers.sql) - [1484. Group Sold Products By The Date](./leetcode/easy/1484.%20Group%20Sold%20Products%20By%20The%20Date.sql) + - [1527. Patients With a Condition](./leetcode/easy/1527.%20Patients%20With%20a%20Condition.sql) - [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) diff --git a/leetcode/easy/1527. Patients With a Condition.sql b/leetcode/easy/1527. Patients With a Condition.sql new file mode 100644 index 0000000..ae6fa59 --- /dev/null +++ b/leetcode/easy/1527. Patients With a Condition.sql @@ -0,0 +1,29 @@ +/* +Question 1527. Patients With a Condition +Link: https://leetcode.com/problems/patients-with-a-condition/description/?envType=study-plan-v2&envId=top-sql-50 + +Table: Patients + ++--------------+---------+ +| Column Name | Type | ++--------------+---------+ +| patient_id | int | +| patient_name | varchar | +| conditions | varchar | ++--------------+---------+ +patient_id is the primary key (column with unique values) for this table. +'conditions' contains 0 or more code separated by spaces. +This table contains information of the patients in the hospital. + + +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. + +Return the result table in any order. +*/ + +SELECT + patient_id, + patient_name, + conditions +FROM Patients +WHERE conditions LIKE '% DIAB1%' OR conditions LIKE 'DIAB1%'