问题
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