문제
입력 코드
1. IF
SELECT
query_name,
ROUND(AVG(rating/position), 2) AS quality,
ROUND(AVG(IF(rating < 3, 1, 0))*100, 2) AS poor_query_percentage
FROM Queries
GROUP BY query_name
2. CASE WHEN
SELECT
query_name,
ROUND(AVG(rating/position), 2) AS quality,
ROUND(SUM(
CASE WHEN rating < 3 THEN 1
ELSE 0
END
) * 100 / COUNT(*), 2) AS poor_query_percentage
FROM Queries
GROUP BY query_name
코드 설명
#SELECT #ROUND #AVG #IF #GROUP BY #SUM #CASE WHEN #COUNT
문제 출처
'SQL' 카테고리의 다른 글
#95. [LeetCode / MySQL] 1174. Immediate Food Delivery II (0) | 2023.09.21 |
---|---|
#94. [LeetCode / MySQL] 1193. Monthly Transactions I (0) | 2023.09.20 |
#92. [LeetCode / MySQL] 1633. Percentage of Users Attended a Contest (0) | 2023.09.18 |
#91. [LeetCode / MySQL] 1075. Project Employees I (0) | 2023.09.17 |
#90. [LeetCode / MySQL] 1251. Average Selling Price (0) | 2023.09.16 |