DolphinDB有类似MySQL的Exists的用法吗

如下图,每个storeId有5组数据,分别是春夏秋冬和过季,如果这5条数据的A字段全部为空,我需要更新过季那条数据B字段的值

attachments-2021-09-cp2JRa6B613377ae709a8.png

不用循环,这张表,当“新品预算”全部是null,才更新最后一条数据“销售季名称=过季”的amount值

请先 登录 后评论

1 个回答

wale

可以用in以及嵌套查询,如:

update t set amount=10 where 销售季名称="过季" and store_code in (exec store_code from (select count(新品预算) as cnt from t group by store_code) where cnt=0)

或者分步查询,如:

code=select store_code from t group by store_code having count(新品预算)=0
update t set amount=10 where  销售季名称="过季" and store_code in code[`store_code]
请先 登录 后评论