๐ข ๋ณธ ํฌ์คํ ์ ํ์ฉ๋๋ ๊ธฐ๋ณธ ๋ฌธ์ ๋ฐ ์๋ฃ ์ถ์ฒ๋
๋ฆฌํธ์ฝ๋ Problems, https://leetcode.com/problemset/all/์์ ๋ฐํ๋๋ค.
โ ๋ฌธ์
https://leetcode.com/problems/patients-with-a-condition/description/
Patients With a Condition - LeetCode
Can you solve this real interview question? Patients With a Condition - Table: Patients +--------------+---------+ | Column Name | Type | +--------------+---------+ | patient_id | int | | patient_name | varchar | | conditions | varchar | +--------------+--
leetcode.com
Table : Patients
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.
…
โ ํ์ด
๋ฌธ์ ์๊ตฌ์ฌํญ
์ 1ํ ๋น๋จ๋ณ ํ์์ ํ์ ID, ํ์ ์ด๋ฆ, ์ํ๋ฅผ ์ฐพ์์ผ ํ๋ค.
์ 1ํ ๋น๋จ๋ณ์ ํญ์ DIAB1 ์ ๋์ฌ๋ก ์์ํ๋ค๊ณ ํ๋ค.
๋ค๋ง, ์์ Output์ ๋ณด๋ฉด ์ ๋์ฌ๊ฐ conditions ๊ฐ์ ๋์ด์ฐ๊ธฐ๋ฅผ ํฌํจํ ๋ค์ ๋จ์ด์ ์ ์ฉ๋๋ conditions ๊ฐ๋ ์ถ๋ ฅํ๋ฏ๋ก
์ด ์ ์ ์ฃผ์ํด์ผ ํ๋ค.
๋ฐ๋ผ์ conditions ์กฐ๊ฑด์ LIKE ๋ฌธ์์ด ํจ์๋ฅผ ์ฌ์ฉํด์ ๋๊ฐ์ง๋ก ์ค์ ํ๋ค.
SELECT patient_id, patient_name, conditions
FROM Patients
WHERE conditions LIKE 'DIAB1%'
OR conditions LIKE '% DIAB1%';
๐ต๏ธโ๏ธ WHERE conditions LIKE '%DIAB1%'์ด ๋ถ๊ฐ๋ฅํ ์ด์ ๋
์๋์ ๊ฐ์ conditions ๊ฐ์ด ์กด์ฌํ๊ธฐ ๋๋ฌธ์ด๋ค. ์ด ๊ฒฝ์ฐ๋ DIAB1 ์ ๋์ฌ ์กฐ๊ฑด์ ์ถฉ์กฑํ์ง ๋ชปํ๋ค.
'Growth ๐ณ > Practice ๐ป' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค] ์ค๋ ๊ธฐ๊ฐ ๋ณดํธํ ๋๋ฌผ(2) : 2์ฐจ ํ์ด (0) | 2023.10.25 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค] ์์ n๊ฐ ๋ ์ฝ๋ : 2์ฐจ ํ์ด ์ถ๊ฐ (0) | 2023.10.25 |
[Leet Code] 1873. Calculate Special Bonus (0) | 2023.10.24 |
[Leet Code] 1633. Percentage of Users Attended a Contest (0) | 2023.10.23 |
[Leet Code] 1148. Article Views I (0) | 2023.10.21 |