我正在为广告系列撰写查询,每当我尝试运行它时,我都会收到错误消息,说法语不正确。
select
opp.*
from
(
select
opp.*,
row_number() over (partition by opp.contact_email_address order by opp.status_date desc) as row_number
from
opportunity_data opp
where
opp.email_bounced = 'false'
and opp.email_unsubscribe = 'false'
and opp.first_mkt_medium not in ('partner', 'inbound_outbound')
and opp.latest_mkt_medium not in ('partner', 'inbound_outbound')
and datediff (day, cast(latest_rfq_submitted_date as date), cast(getdate() as date)) > 30
and opp.on_cover = 'no'
and opp.primary_group in ('Market_trader', 'Food_stand', 'Mobile_food_van', 'Caterer')
and opp.site = 'simplybusiness'
and opp.opportunity_status = ('quote_recieved', 'rfq_submitted', 'policy_expired_not_renewed')
) opp
where row_number = 1
答案 0 :(得分:1)
由于您上次where
行而出现错误。你不能这样使用它。我想您想使用in
代替=
:
AND opp.opportunity_status IN ('quote_recieved', 'rfq_submitted', 'policy_expired_not_renewed')
答案 1 :(得分:1)
检查:
select
opp.*
from
(
select
opp.*,
row_number() over (partition by opp.contact_email_address order by opp.status_date desc) as row_number
from
opportunity_data opp
where
opp.email_bounced = 'false'
and opp.email_unsubscribe = 'false'
and opp.first_mkt_medium not in ('partner', 'inbound_outbound')
and opp.latest_mkt_medium not in ('partner', 'inbound_outbound')
and datediff (day, cast(latest_rfq_submitted_date as date), cast(getdate() as date)) > 30
and opp.on_cover = 'no'
and opp.primary_group in ('Market_trader', 'Food_stand', 'Mobile_food_van', 'Caterer')
and opp.site = 'simplybusiness'
and opp.opportunity_status in ('quote_recieved', 'rfq_submitted', 'policy_expired_not_renewed')
) opp
where row_number = 1