我正在尝试回答一个特定的问题:“哪个电影类别在我们的客户中最受欢迎?”我可以修改此查询:
SELECT f.title, COUNT(*) AS RentalCount
FROM film f
INNER JOIN film_category fc ON fc.film_id = f.film_id
INNER JOIN category c ON c.category_id = fc.category_id
INNER JOIN inventory i ON i.film_id = f.film_id
INNER JOIN rental r ON r.inventory_id = i.inventory_id
WHERE (c.name = 'Sports')
GROUP BY f.title
ORDER BY 2 DESC;
谢谢!
答案 0 :(得分:0)
您与查询非常接近。基本上,您只需要按类别进行汇总:
dict = {}
choice = input("What is your choice? ")
if choice in dict:
dict[choice] += 1
else:
dict[choice] = 1
print(dict)
> {'orange': 1}