简体   繁体   English

如何解决此语法错误?

[英]How can I resolve this syntax error?

Im trying to write a query to pull customer data for an email. 我试图编写查询以提取电子邮件的客户数据。 this is the query: 这是查询:

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.site = 'wesellinsurance'
 and opp.email_bounced = 'false'
 and opp.email_unsubscribed = 'false'
 and opp.first_mkt_medium not in ('partner', 'inbound_outbound')
 and opp.latest_mkt_medium not in ('partner','inbound_outbound')
 and opp.on_cover = 'false'
 and opp.primary_group in ('market_trader', 'food_stand', 'mobile_food_van', 'caterer')
 and opp.opportunity_status = ('quote_recieved','rfq_submitted', 'policy_expired_not_renewed')
 and datediff(day, cast(latest_rfq_submitted_date as date),cast(getdate() as date)) > 30
 and opp.lifecycle = 'new_business'
 ) opp
where row_number = 1

most syntax analysers say theres an issue on line 7 but i cant seem to see it 大多数语法分析器说第7行存在问题,但我似乎看不到它

In is missing on line 18 第18行缺少In

 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.site = 'wesellinsurance'
        and opp.email_bounced = 'false'
        and opp.email_unsubscribed = 'false'
        and opp.first_mkt_medium not in ('partner', 'inbound_outbound')
        and opp.latest_mkt_medium not in ('partner','inbound_outbound')
        and opp.on_cover = 'false'
        and opp.primary_group in ('market_trader', 'food_stand', 'mobile_food_van', 'caterer')
        and opp.opportunity_status in ('quote_recieved','rfq_submitted', 'policy_expired_not_renewed')
                     --------------^
        and datediff(day, cast(latest_rfq_submitted_date as date),cast(getdate() as date)) > 30
        and opp.lifecycle = 'new_business'
     ) opp
    where row_number = 1

Error is (there should be (in) instead of (=) and always specify a table name BEST PRACTISE (opp1.row_number)) 错误是(应该使用(输入)而不是(=),并且始终指定表名称BEST PRACTICE(opp1.row_number))

 select
         opp1.*
        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.site = 'wesellinsurance'
         and opp.email_bounced = 'false'
         and opp.email_unsubscribed = 'false'
         and opp.first_mkt_medium not in ('partner', 'inbound_outbound')
         and opp.latest_mkt_medium not in ('partner','inbound_outbound')
         and opp.on_cover = 'false'
         and opp.primary_group in ('market_trader', 'food_stand', 'mobile_food_van', 'caterer')
         and opp.opportunity_status in ('quote_recieved','rfq_submitted', 'policy_expired_not_renewed')
         and datediff(day, cast(latest_rfq_submitted_date as date),cast(getdate() as date)) > 30
         and opp.lifecycle = 'new_business'
         ) opp1
        where opp1.row_number = 1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何解决此错误 - ERROR 1064 (42000): 您的 SQL 语法有错误 - How can i resolve this error - ERROR 1064 (42000): You have an error in your SQL syntax 当我无法发现问题时,如何解决 SQL ERROR 1604 语法错误? - How to resolve SQL ERROR 1604 Syntax error when I can't spot the issue? 如何确定MySQL中的语法错误 - How can I pinpoint a syntax error in MySQL 如何使用语法和外键解决SQL错误 - how to resolve SQL error with syntax and foreign key 如何解决 VB.net 中的此类错误? MySql.Data.MySqlClient.MySqlException: '您的 Sql 语法有错误; 看说明书……” - how can i resolve this kind of error in VB.net? MySql.Data.MySqlClient.MySqlException: 'You have an error in your Sql syntax; check the manual…' 如何解决MYSQL / PHP中的“资源ID#8”错误消息? - How can I resolve the “Resource ID #8” error message in MYSQL/PHP? 如何解决我的数据库迁移中的排序规则错误? - How can I resolve a collation error in my DB migration? 我该如何解决这个问题,它在 @Column 注释上显示错误? - How I can resolve this issue, It showing Error on @Column annotation? 如何解决致命的SQL语句错误? - How can I resolve a fatal SQL statement error? 如何解决 MYSQL 8.0 中的 1290 错误代码 - How can I resolve 1290 error code in MYSQL 8.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM