๐ข ๋ณธ ํฌ์คํ ์ ํ์ฉ๋๋ ๊ธฐ๋ณธ ๋ฌธ์ ๋ฐ ์๋ฃ ์ถ์ฒ๋
๋ฆฌํธ์ฝ๋ Problems, https://leetcode.com/problemset/all/์์ ๋ฐํ๋๋ค.
โ๋ฌธ์
https://leetcode.com/problems/immediate-food-delivery-i/description/
Table : Delivery
If the customer's preferred delivery date is the same as the order date, then the order is called immediate; otherwise, it is called scheduled.
Find the percentage of immediate orders in the table, rounded to 2 decimal places.
The result format is in the following example.
โ ํ์ด
๋ฌธ์ ์๊ตฌ์ฌํญ
๊ณ ๊ฐ์ด ์ ํธํ๋ ๋ฐฐ์ก์ผ์๊ฐ ์ฃผ๋ฌธ์ผ์์ ๋์ผํ๋ค๋ฉด, ์ฃผ๋ฌธ์ 'immediate' (์ฆ์์ฃผ๋ฌธ)
๊ทธ๋ ์ง ์์ผ๋ฉด 'scheduled' (์์ฝ์ฃผ๋ฌธ) ๋ก ์ ์ํ๋ค. ์ฆ์์ฃผ๋ฌธ์ด ์ผ๋ง๋ ๋๋์ง ๋น์จ์ ์ถ๋ ฅํด์ผ ํ๋ค.
(๋น์จ ๊ณ์ฐ์ ์ฝ๊ฒ ํ๋ ค๊ณ 1, 0์ผ๋ก ์ ์ํ๋ค. 1 = 'immediate', 0 = 'scheduled')
immediate percentage = ( immediate ์ฃผ๋ฌธ๊ฑด์ / ์ ์ฒด ์ฃผ๋ฌธ๊ฑด์ ) × 100
* ์์์ ๋์งธ์๋ฆฌ ๋ฐ์ฌ๋ฆผ ์ฒ๋ฆฌ
SELECT ROUND((SUM(CASE WHEN order_date = customer_pref_delivery_date
THEN 1 ELSE 0 END) / COUNT(*)) * 100, 2) AS immediate_percentage
FROM Delivery
'Growth ๐ณ > Practice ๐ป' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Leet code] 1050. Actors and Directors Who Cooperated At Least Three Times (2) | 2023.09.08 |
---|---|
[Leet code] 619. Biggest Single Number (0) | 2023.09.02 |
[Leet code] 1164. Product Price at a Given Date (0) | 2023.07.17 |
[LeetCode] 1321. Restaurant Growth (3) | 2023.06.17 |
[LeetCode] 1158. Market Analysis I (0) | 2023.06.08 |