从未使用过太多的MYSQL,这是一个复杂的示例,所以在此先感谢。 我希望通过COD_DUE_DATE取消以下查询。因此,我希望CASE_ID在该列的下方,并沿着该列我需要4个部分:-不到一周的时间,一个星期,两个星期的时间,三个星期等。 然后中间的值将是CASE_ID的计数
SELECT DISTINCT a.CASE_ID, b.BUCKET, a.CUSTOMER_OCCUPATION_DATE,
CASE
WHEN a.CUSTOMER_OCCUPATION_DATE BETWEEN SYSDATE-10000 AND SYSDATE+7 THEN 'LESS THAN 1 WEEK'
WHEN a.CUSTOMER_OCCUPATION_DATE BETWEEN SYSDATE+8 AND SYSDATE+14 THEN 'DUE IN 1 WEEK'
WHEN a.CUSTOMER_OCCUPATION_DATE BETWEEN SYSDATE+15 AND SYSDATE+21 THEN 'DUE IN 2 WEEKS'
WHEN a.CUSTOMER_OCCUPATION_DATE BETWEEN SYSDATE+22 AND SYSDATE+28 THEN 'DUE IN 3 WEEKS'
ELSE 'DUE IN 4+ WEEKS'
END as COD_DUE_DATE
FROM FND_COMPLAINTS a, FTTP_NEWSITES_DWELL_DETAIL b,
unpivot
(
a.CUSTOMER_OCCUPATION_DATE
for COD_DUE_DATE in (LESS THAN 1 WEEK)
)
WHERE a.NAD_KEY = b.NAD(+) AND a.CUSTOMER_OCCUPATION_DATE IS NOT NULL
ORDER BY a.CUSTOMER_OCCUPATION_DATE ASC