LeetCode(数据库)- The Category of Each Member in the Store
Posted 程序员牧码
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode(数据库)- The Category of Each Member in the Store相关的知识,希望对你有一定的参考价值。
题目链接:点击打开链接
题目大意:略。
解题思路:略。
AC 代码
WITH t AS(SELECT member_id, COUNT(IFNULL(charged_amount, NULL)) * 100 / COUNT(*) score
FROM Visits LEFT JOIN Purchases USING(visit_id)
GROUP BY 1)
SELECT m.member_id, m.name, CASE
WHEN score IS NULL THEN 'Bronze'
WHEN score >= 80 THEN 'Diamond'
WHEN score >= 50 THEN 'Gold'
ELSE 'Silver'
END category
FROM Members m LEFT JOIN t USING(member_id)
以上是关于LeetCode(数据库)- The Category of Each Member in the Store的主要内容,如果未能解决你的问题,请参考以下文章
LeetCode(数据库)- The Number of Seniors and Juniors to Join the Company
LeetCode(数据库)- The Number of Seniors and Juniors to Join the Company
LeetCode(数据库)- Build the Equation
LeetCode(数据库)- Build the Equation
LeetCode(数据库)- The Number of Seniors and Juniors to Join the Company II
LeetCode(数据库)- The Number of Seniors and Juniors to Join the Company II