2016-11-10 4 views
0

私はキャンペーンのクエリを書いています。実行しようとするたびに、構文が正しくないというエラーが表示されます。「近くの構文が正しくありません」、「」を解決するにはどうすればよいですか?

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

等 – jarlh

+0

、いくつかのコードを削除し再試行し、いくつかのより多くのコードを削除し、再試行完全なエラーメッセージを追加してください。 –

+0

ようこそスタックオーバーフロー!人々があなたの質問に答えるのを助けるためには、エラーについてより具体的に説明する必要があります。投稿を編集して[mcve]のコンパイルから得られる正確なエラーを組み込むようにしてください(できれば、コピー+貼り付けを使用して転写エラーを回避してください)。 –

答えて

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 
+0

ウィンターがあります – TastyBurgers

1

最後のwhere行のためにエラーが表示されます。あなたはこのように使用することはできません。私はあなたがin代わりの=を使用したいと思う:これで

AND opp.opportunity_status IN ('quote_recieved', 'rfq_submitted', 'policy_expired_not_renewed') 
関連する問題