[LeetCode/SQL] 1211. Queries Quality and Percentage

Sooyeon·2023년 11월 13일
0

문제풀이 

목록 보기
41/95
post-thumbnail

[LeetCode/SQL]


📌 1211. Queries Quality and Percentage

문제

풀이

- 쿼리의 품질(quality)과 나쁜 쿼리의 비율(poor_query_percentage) 출력
- query_name,quality,poor_query_percentage 출력
- 3자리에서 반올림 

풀이

SELECT query_name,
      ROUND(SUM(rating/position)/COUNT(*),2) AS quality,
      ROUND(SUM(CASE WHEN rating<3 THEN 1 ELSE 0 END)/COUNT(*)*100,2) 
      AS poor_query_percentage
FROM Queries
GROUP BY query_name

0개의 댓글