我是SQL新手,正在努力应对一个案例。 我想使其中如果一个帐户(ACCOUNT_ID)不具有一个记录(ON BILLING_ID)CURRENT_DATE-302和CURRENT_DATE-62之间的情况下然后标记为“1”案例SQL如果在日期之间没有记录
以下查询:
在此先感谢
SELECT
billing_date_local_time
,account_id
,contract_owner_name
,date_first_feature_partner
,deal_starts_at
,contract_id
,new_partner_type
,sum(voucher_sold) AS Vouchers
,sum(gross_bookings_local) AS GB
,sum(gross_revenue_local) AS GR
,is_G2
,Case when billing_date_local_time between current_date-302 and current_date-62 = 0 THEN 'YES' ELSE 'NO' End
FROM EMEA_ANALYTICS.eu_deal_flat
WHERE
country_id = 206
and billing_date_local_time between current_date-400
and current_date-2
GROUP BY 1,2,3,4,5,6,10,11
删除= 0 CURRENT_DATE-62后。这解决了你的问题。 –
你究竟是什么意思*标记为“1”*? – Bohemian