我希望每次都将结果限制在前 7 天,但是此查询总是抛出错误并且似乎没有按预期工作:
SELECT
DD.DATE_DATE AS Rcv_Date,
elig.PL_PREMIUMDESC,
COUNT(DISTINCT(sERV.claim_nbr)) as Claim_Nbr
from
ft_service SERV
inner join ft_claim claim
on SERV.claim_nbr=claim.claim_nbr
inner join medical_cost_category mcc
on SERV.medical_cost_category_dim_ck=mcc.medical_cost_category_dim_ck
INNER JOIN DIM_DATE DD
ON DD.DATE_DIM_CK = CLAIM.RCVD_DATE_DIM_CK
left join member_elig_curr elig
on SERV.member_elig_curr_ck=elig.member_elig_curr_ck
WHERE DD.DATE_DATE - ((DD.DATE_DATE - CURRENT_DATE) MOD 7) ---GET ME PREVIOUS 7 DATS FOR
RCV DATE
AND elig.PL_CODE IN ('XXX', 'XXXA', 'XXXB')
AND SERV.CLAIM_NBR NOT LIKE '%XD%'
GROUP BY 1, 2