Vertica:子查询 OR 和相关表错误

Vertica: Subquery OR and co related tables error

模型数据

收入Table

我正在尝试找出我的模型性能,即我在 5 月 (5) 的 model_month 为 Model_year(2015 ) 现在跟踪性能我正在跟踪收入。

我声称型号有效期为 3 个月,因此为了检查性能,我想在型号 table 旁边看到一个新列,在 model_month 之后有 3 个月的收入。

SELECT a.*,
case    when (a.MODEL_MONTH<10 ) then   (select sum(b.net_revenue) from Revenue as b
                                        where ((b.cal_month > a.MODEL_MONTH OR  b.cal_month<a.MODEL_MONTH+4) AND b.cal_year=a.MODEL_YEAR)
                                                    and a.model_BU=b.prodcat a.model_region=b.hp_region)

        when (a.MODEL_MONTH>=10) then   (select sum(b.net_revenue) from Revenue b
                                        where (((b.cal_month > a.MODEL_MONTH and b.cal_year=a.MODEL_YEAR) || 
                                                (b.cal_month < a.MODEL_MONTH-9 and b.cal_year=a.MODEL_YEAR+1)) AND a.model_BU=b.prodcat))
        ELSE '0'
        END as Net_Revenue

        FROM ModelData as a
        limit 10        
        ;

我遇到了以下错误 错误:[Vertica]VJDBC 错误:不支持非等式相关子查询表达式 SQL状态:HY000 错误代码:4160

是的,这是正确的。

如您在 Vertica 文档中所见:

分析数据指南 > 编写查询 > 子查询 > 子查询限制:

Multiple correlations are allowed only for subqueries that are joined with an equality predicate

关于Correlated Subquery

的一般信息