我有表是这样的:相关子查询模式不支持错误
您可以注意到有在serp_flag列空多值。我需要填补这些领域。它必须填充以前的非空值。所以,如果我的最后一个非空值是1,那么之后的所有空字段应该是1,除非非空字段出现。同样,如果最后一个非null值为0,那么之后的所有空字段都应为0.此表具有数百万条记录。
错误:Invalid operation:This type of correlated subquery pattern is not supported yet;
使用PostgreSQL和红移。
我的查询:
select event_id, domain_userid, collector_tstamp, se_category, se_action, se_label, se_property,
CASE WHEN serp_flag = 0 THEN 0
WHEN serp_flag = 1 THEN 1
WHEN serp_flag is null then (select serp_flag from (select t2.serp_flag,(t1.collector_tstamp - t2.collector_tstamp) as time_diff from temp.serp_funnel t2
where t1.domain_userid = t2.domain_userid and (t1.collector_tstamp - t2.collector_tstamp) >= 0 and t2.serp_flag is not null order by time_diff limit 1))
END
from temp.serp_funnel t1
limit 100;
这是我的表(的一部分)的外观
|------------|----------------|--------------|
|domainid |timestamp |serp_flag |
|------------|----------------|--------------|
|d1 |t1 |1 |
|------------|----------------|--------------|
|d1 |t2 |null |
|------------|----------------|--------------|
|d1 |t3 |null |
|------------|----------------|--------------|
|d1 |t4 |0 |
|------------|----------------|--------------|
|d1 |t5 |null |
|------------|----------------|--------------|
这是我想
|------------|----------------|--------------|
|domainid |timestamp |serp_flag |
|------------|----------------|--------------|
|d1 |t1 |1 |
|------------|----------------|--------------|
|d1 |t2 |1 |
|------------|----------------|--------------|
|d1 |t3 |1 |
|------------|----------------|--------------|
|d1 |t4 |0 |
|------------|----------------|--------------|
|d1 |t5 |0 |
|------------|----------------|--------------|
而且时间戳进行排序每个什么域用户。
http://meta.stackoverflow.com/questions/285551/why-may-i-not-upload-images-of-code-on-so-when-asking-a-question/285557#285557 –