Table A
----------------
Date index
------------------
2016-10-20 2.3
2016-10-21 2.8
------- ---
------- ---
Table B:
--------
Code Life_completed
A 5
b 6
实际查询:
select *,(select sum(index)
from table1
where date between current_date +3 AND current_date
) as Index
from table b
预期查询:
我们可以用current_date +Life_completed
我们正在使用vertica数据库..
请在这里帮忙..
答案 0 :(得分:0)
此相关子查询与左连接加上总和相同:
select b.Code, b.Life_completed,
sum(a.index) as Index
from tableB b
left join tableA as a
on a.date between current_date AND current_date + B.life_completed