【问题标题】:An expression of non-boolean type specified in a context where a condition is expected, near 'end'. error在预期条件的上下文中指定的非布尔类型的表达式,靠近“结束”。错误
【发布时间】:2016-03-23 18:08:58
【问题描述】:
select *
from DBNAME.dbo.Shell_V36 V
inner join 
DBNAME.DBO.Promo P 
on 
Case  
when 
(V.Product = P.From_Product_Code) 
And  (V.cur_date >= P.Promo_end_date)
or (V.cur_date <= P.Promo_start_date)
then (P.To_Product_Code)
else(P.From_Product_Code)
end 

我收到“在预期条件的上下文中指定的非布尔类型的表达式,靠近‘结束’。”谁能帮帮我。

【问题讨论】:

标签: sql-server sql-server-2008


【解决方案1】:

您必须提供JOIN 操作的ON 子句中使用的Shell_V36 表中的字段:

select *
from DBNAME.dbo.Shell_V36 V
inner join DBNAME.DBO.Promo P 
on Case when 
           (V.Product = P.From_Product_Code) And  
           (V.cur_date >= P.Promo_end_date)
           or 
           (V.cur_date <= P.Promo_start_date)
         then (P.To_Product_Code)
         else (P.From_Product_Code)
   End = V.code -- presumably code field should be used 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-23
    • 1970-01-01
    • 2017-08-29
    相关资源
    最近更新 更多