Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.3k 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 Reply

0 votes
by (71.8m points)

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

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...