Teradata MAX 功能 [英] Teradata MAX function
本文介绍了Teradata MAX 功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我们使用下面的函数会返回哪一行?
Which row will be return if we use following function?
MAX (NAME)
我们在名称列中有以下两行
Where we have following two rows in name column
1 ABC
2 ABC
推荐答案
两者都不是.将返回一个不绑定到任一行的聚合,而是 Max(Name)
值,显然必须是 ABC
因为它是唯一可用的值:
Neither. An aggregate will be returned that is not tied to either row, but rather the Max(Name)
value, which will obviously have to be ABC
as it's the only value available:
CREATE VOLATILE TABLE test
(
f1 INTEGER,
f2 CHAR(3)
) PRIMARY INDEX (f1) ON COMMIT PRESERVE ROWS;
INSERT INTO test VALUES (1, 'ABC');
INSERT INTO test VALUES (2, 'ABC');
SELECT MAX(f2) FROM test;
DROP TABLE test;
只返回ABC
你可以这样想.如果我在白板上写下数字2
,让你大声说出哪个最大,你会说2";问你选择了哪个'两个'?"是很愚蠢的.
You can think of it this way. If I write the number 2
on a whiteboard and ask you to say out loud which one is the largest, you will say "2"; it would be silly to ask "Which 'two' did you pick though?".
这篇关于Teradata MAX 功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文