我要对属于特定电影类别(动画,儿童等)的特定四分位数(1、2、3或4)的电影进行计数
我的查询在这里显示电影的类别,四分位数和计数。但是我只想清楚地区分每个类别中的每个四分位数。
这是我的查询。??
WITH t1 AS (
SELECT f.title, c.name, f.rental_duration
FROM film f
JOIN film_category fc
ON fc.film_id=f.film_id
JOIN category c
ON c.category_id=fc.category_id
WHERE c.name IN ('Animation', 'Children', 'Classics', 'Comedy', 'Family', 'Music')),
t2 AS (
SELECT t1.name, NTILE(4) OVER(ORDER BY t1.rental_duration) AS standard_quartile
FROM t1)
SELECT t2.name, t2.standard_quartile, COUNT(t2.name) OVER (PARTITION BY standard_quartile ORDER BY t2.name)
FROM t2
结果表应如下所示。