Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.2k views
in Technique[技术] by (71.8m points)

为什么iif返回了一个字典?

date = table(2020.01.01..2020.01.10 as date);
ticker = table(AB`C$SYMBOL as ticker);
t = select *, iif(ticker=="A", 1, 0) as value from cj(date, ticker);
update t set v2 = select iif(date==2020.01.08, 10, 11) from t;

以上代码运行之后,t中v2列成为了一个DICTIONARY(第一个iif运算应该是符合预期的,第二个iif并没有返回10或者11的数字,而是一个字典):

t;
date ticker value v2


2020.01.01 A 1 iif->11
2020.01.01 B 0 iif->11
2020.01.01 C 0 iif->11
2020.01.02 A 1 iif->11


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

select语句总是生成一张表,即使只选择一列亦是如此。若需要生成一个标量或者一个向量,可使用exec语句。

update t set v2 = exec iif(date==2020.01.08, 10, 11) from t;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...