Teradata MAX function

ぃ、小莉子 提交于 2019-12-11 18:34:08

问题


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

回答1:


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;

Which just returns ABC

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?".




回答2:


Since both the values are same and there are only two row,You will get the output as "ABC" when you try to find the max



来源:https://stackoverflow.com/questions/52318683/teradata-max-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!