简体   繁体   English

AWS Athena max 函数如何处理 Null 值

[英]How does AWS Athena max function deals with Null values

I have a table in AWS Athena with a column that contains NULL values.我在 AWS Athena 中有一个表,其中包含一个包含 NULL 值的列。

I want to calculate the max value for this column.我想计算此列的最大值。

How would Athena calculate max value for a column that contains both Nulls and non-Nulls? Athena 如何计算包含空值和非空值的列的最大值?

For the following example:对于以下示例:

在此处输入图片说明

What would be the output for the following query:以下查询的输出是什么:

select max(uploaded_mb) from table_name;

The Presto max() function returns the maximum value of all input values. Presto max()函数返回所有输入值的最大值。 Nulls won't affect that.空值不会影响它。

Here's an example query that shows that NULLs are ignored:下面是一个示例查询,显示 NULL 被忽略:

WITH
  t1 AS (SELECT 1 AS a),
  t2 AS (SELECT NULL AS a),
  tf AS (
    SELECT * FROM t1
    UNION ALL 
    SELECT * FROM t2
  )
SELECT max(a)
FROM tf

Did you get an error or see unexpected behaviour when using max() ?使用max()时是否遇到错误或看到意外行为?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM